This repository was archived by the owner on May 25, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
projects/Find IMDb rating Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ < << << << HEAD
1
2
import requests
2
3
from bs4 import BeautifulSoup
3
4
27
28
print (f"Rating of { name } :" , rating )
28
29
except Exception :
29
30
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
+ >> >> >> > 663865 b3e02855d6e855bd86f1554501fa532715
You can’t perform that action at this time.
0 commit comments