Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit 663865b

Browse files
authored
Add files via upload
Script to fetch IMDb rating
1 parent 7323e3b commit 663865b

File tree

1 file changed

+26
-0
lines changed

1 file changed

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /