Skip to content

Commit cc937b3

Browse files
Merge pull request geekcomputers#97 from Henocks/patch-12
tiny visual update
2 parents e5e6d69 + c0b14f1 commit cc937b3

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

movie_details

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import mechanize
2-
from bs4 import BeautifulSoup
32
import urllib2
3+
from bs4 import BeautifulSoup
4+
45
# Create a Browser
56
b = mechanize.Browser()
67

@@ -16,38 +17,37 @@ b.open('http://www.imdb.com/search/title')
1617
# Choose a form
1718
b.select_form(nr=1)
1819

19-
2020
b['title'] = nm
2121

2222
b.find_control(type="checkbox",nr=0).get("feature").selected = True
2323

2424

2525
# Submit
26-
fd = b.submit()
27-
26+
fd = b.submit()
2827
soup = BeautifulSoup(fd.read(),'html5lib')
2928

3029
#data= soup.find_all('td',class_="title")
3130
#for div in data:
3231
# links= div.find_all('a')
33-
# for a in links:
34-
# print a['href'];
32+
# for a in links:
33+
# print a['href'];
3534

3635

3736
for div in soup.findAll('td', {'class': 'title'},limit=1):
3837
a = div.findAll('a')[0]
39-
print a.text.strip(), '=>', a.attrs['href']
40-
hht='http://www.imdb.com'+a.attrs['href']
38+
print (a.text.strip(), '=>', a.attrs['href'])
39+
hht = 'http://www.imdb.com'+a.attrs['href']
4140
print(hht)
42-
page=urllib2.urlopen(hht)
41+
page = urllib2.urlopen(hht)
4342
soup2 = BeautifulSoup(page.read(),'html.parser')
44-
print("title of the movie: ")
43+
44+
print( "title of the movie: ")
4545
print(soup2.find(itemprop="name").get_text())
46-
print("timerun: ")
46+
print( "timerun: ")
4747
print(soup2.find(itemprop="duration").get_text())
48-
print("genre: ")
48+
print( "genre: ")
4949
print(soup2.find(itemprop="genre").get_text())
5050
print("current IMDB rating:")
5151
print(soup2.find(itemprop="ratingValue").get_text())
52-
print("summary:")
52+
print( "summary:")
5353
print(soup2.find(itemprop="description").get_text())

0 commit comments

Comments
 (0)