-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmovie review generator.py
More file actions
35 lines (31 loc) · 1012 Bytes
/
movie review generator.py
File metadata and controls
35 lines (31 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import bs4
import urllib.request as url
userInput = input("Enter movie name : ")
userInput1 = userInput.split()
movieName = '+'.join(userInput1)
http = url.urlopen("https://www.imdb.com/find?ref_=nv_sr_fn&q="+movieName)
source = bs4.BeautifulSoup(http,'lxml')
td = source.find('td',class_='result_text')
a = td.find('a')
# print(a['href'])
href = a['href']
newUrl = "https://www.imdb.com" + href
http = url.urlopen(newUrl)
source = bs4.BeautifulSoup(http,'lxml')
div = source.find('div', class_='title_wrapper')
# print(div.text)
data = div.text.replace("\n","")
# print(data.split())
data = data.split()
data = ' '.join(data)
print(data)
summary = source.find('div', class_='summary_text')
print(summary.text.strip())
links = source.findAll('a',class_='quicklink')
#print(links)
url2 = "https://www.imdb.com" + links[2]['href']
http = url.urlopen(url2)
source = bs4.BeautifulSoup(http)
titles = source.findAll('a', class_='title')
for item in titles:
print(item.text)