Created
June 13, 2023 11:28
Revisions
-
nip10 created this gist
Jun 13, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ # instructions: # pip3 install requests # python3 app.py import requests import json def fetch_and_print_data(): url = "https://www.cinemas.nos.pt/graphql/execute.json/cinemas/getTopMovies" response = requests.get(url) if response.status_code == 200: data = json.loads(response.text) items = data["data"]["movieList"]["items"] pre_sale_movies = [item for item in items if item["moviestate"] == "PreSale"] print("Movies in PreSale state:") for movie in pre_sale_movies: print(movie["title"]) oppenheimer_movies = [item for item in items if "oppenheimer" in item["originaltitle"].lower()] if oppenheimer_movies: print("\nMovies with 'Oppenheimer' in the original title:") for movie in oppenheimer_movies: print(movie["title"]) else: print("\nNo movie with 'Oppenheimer' in the original title found.") else: print("Failed to fetch data from the endpoint.") if __name__ == "__main__": fetch_and_print_data()