Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit 7bcd97c

Browse files
committed
updated as per guidelines
1 parent 7323e3b commit 7bcd97c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
4+
# Defining variables and url
5+
title = str(input("Enter the title of movie/series: ")).lower()
6+
release = str(input("Enter the year of release: ")).lower()
7+
query = "+".join(title.split())
8+
URL = f"https://www.imdb.com/search/title/?title={query}"
9+
10+
s = requests.session() # Setting up session
11+
12+
try:
13+
response = s.get(URL)
14+
soup = BeautifulSoup(response.content, features="lxml")
15+
containers = soup.find_all("div", class_="lister-item-content")
16+
17+
for result in containers:
18+
name = result.h3.a.text.lower()
19+
year = result.h3.find(
20+
"span", class_="lister-item-year text-muted unbold"
21+
).text.lower()
22+
23+
if title in name and release in year:
24+
rating = result.find("div",
25+
class_="inline-block ratings-imdb-rating")[
26+
"data-value"]
27+
print(f"Rating of {name}:", rating)
28+
except Exception:
29+
print("Try again with valid combination of tile and release year")

0 commit comments

Comments
 (0)