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

Commit d62e4d3

Browse files
committed
fixes
2 parents 7bcd97c + 663865b commit d62e4d3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

projects/Find IMDb rating/find_IMDb_rating.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<<<<<<< HEAD
12
import requests
23
from bs4 import BeautifulSoup
34

@@ -27,3 +28,31 @@
2728
print(f"Rating of {name}:", rating)
2829
except Exception:
2930
print("Try again with valid combination of tile and release year")
31+
=======
32+
import requests
33+
from bs4 import BeautifulSoup
34+
import lxml
35+
36+
#defining variables and url
37+
title= str(input("Enter the title of movie/series: ")).lower()
38+
release= str(input("Enter the year of release: ")).lower()
39+
query='+'.join(title.split())
40+
URL= f'https://www.imdb.com/search/title/?title={query}'
41+
42+
s=requests.session() #setting up session
43+
44+
try:
45+
response= s.get(URL)
46+
soup= BeautifulSoup(response.content, 'lxml')
47+
containers=soup.find_all('div', class_='lister-item-content')
48+
49+
for result in containers:
50+
name= result.h3.a.text.lower()
51+
year= result.h3.find('span', class_='lister-item-year text-muted unbold').text.lower()
52+
53+
if title in name and release in year:
54+
rating= result.find('div', class_='inline-block ratings-imdb-rating')['data-value']
55+
print(f'Rating of {title}:', rating)
56+
except:
57+
print("Try again with valid combination of tile and release year")
58+
>>>>>>> 663865b3e02855d6e855bd86f1554501fa532715

0 commit comments

Comments
 (0)