Skip to content

Instantly share code, notes, and snippets.

@nip10
Created June 13, 2023 11:28

Revisions

  1. nip10 created this gist Jun 13, 2023.
    32 changes: 32 additions & 0 deletions app.py
    Original 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()