Skip to content

Commit 5475eb7

Browse files
committed
Fetching IMDB Rating Completed
1 parent 425dd48 commit 5475eb7

1 file changed

Lines changed: 10 additions & 27 deletions

File tree

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,21 @@
11
import requests
2-
from bs4 import BeautifulSoup
2+
import json
33

44
# Defining variables and url
55
title = str(input("Enter the title of movie/series: "))
6-
release = str(input("Enter the year of release: "))
6+
year = str(input("Enter the year of release: "))
77
query = "+".join(title.split())
8-
#RL = f"https://www.imdb.com/search/title/?title={query}"
98

109
request_link = 'http://www.omdbapi.com/?i=tt3896198&apikey=2c84f11f'
1110

12-
#api_key = 2c84f11f
11+
#final request link using OMDb API
12+
request = request_link + '&t=' + query + '&y=' + year
1313

14-
request = request_link + '&t=' + query
15-
result = requests.get(request)
14+
#requesting data from OMBd
15+
response = requests.get(request)
1616

17-
print(result.text)
17+
#converting to json (dictionary)
18+
response = response.json()
1819

19-
# s = requests.session() # Setting up session
20-
21-
# try:
22-
# response = s.get(URL)
23-
# soup = BeautifulSoup(response.content, features="lxml")
24-
# containers = soup.find_all("div", class_="lister-item-content")
25-
26-
# for result in containers:
27-
# name = result.h3.a.text.lower()
28-
# year = result.h3.find(
29-
# "span", class_="lister-item-year text-muted unbold"
30-
# ).text.lower()
31-
32-
# if title in name and release in year:
33-
# rating = result.find("div",
34-
# class_="inline-block ratings-imdb-rating")[
35-
# "data-value"]
36-
# print(f"Rating of {name}:", rating)
37-
# except Exception:
38-
# print("Try again with valid combination of tile and release year")
20+
#printing imdb rating
21+
print(response['imdbRating'])

0 commit comments

Comments
 (0)