Created
June 13, 2023 11:28
-
-
Save nip10/2e656f5da053829f933629b51be678c5 to your computer and use it in GitHub Desktop.
presale movies
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 characters
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment