|
1 | | -<<<<<<< HEAD |
2 | 1 | import requests
|
3 | 2 | from bs4 import BeautifulSoup
|
4 | 3 |
|
|
28 | 27 | print(f"Rating of {name}:", rating)
|
29 | 28 | except Exception:
|
30 | 29 | 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