Skip to content

Commit

Permalink
Update IMDb.py
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyuploader committed Nov 2, 2024
1 parent 9405b9e commit b610c4c
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions IMDb.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ def fetch_popular_movies() -> list[dict]:
list of dict: A list where each dictionary contains Movie information,
such as the Movie's name, link, and rating.
"""
print(f"Fetching Popular Movies {CURRENT_YEAR} from IMDb ->", IMDB_POPULAR_MOVIES_URL)
print(
f"Fetching Popular Movies {CURRENT_YEAR} from IMDb ->", IMDB_POPULAR_MOVIES_URL
)

movie_data = []

response = get(IMDB_POPULAR_MOVIES_URL, headers=HEADERS)
soup = BeautifulSoup(response.text, "html.parser")

json_data = (
json.loads(soup.find("script", type="application/ld+json").text)
)
json_data = json.loads(soup.find("script", type="application/ld+json").text)
for movie in json_data["itemListElement"]:
movie_name = movie["item"]["name"]
try:
Expand All @@ -64,16 +64,11 @@ def fetch_popular_movies() -> list[dict]:
movie_rating = 0
movie_link = movie["item"]["url"]
movie_data.append(
{
"name": movie_name,
"rating": movie_rating,
"link": movie_link
}
{"name": movie_name, "rating": movie_rating, "link": movie_link}
)
return movie_data



def fetch_top_50_movies() -> list[dict]:
"""
Fetch information about the Top 50 Movies of the current year from IMDb.
Expand Down

0 comments on commit b610c4c

Please sign in to comment.