<p>我对WebScraping/Python和beauthoulsoup还不熟悉,我的代码很难正常工作。在</p>
<p>我想通过url:<a href="http://m.imdb.com/feature/bornondate" rel="nofollow">http://m.imdb.com/feature/bornondate</a>“获取:</p>
<ul>
<li>名人的名字</li>
<li>名人形象</li>
<li>专业</li>
<li>最好的作品</li>
</ul>
<p>为那一页上的十位名人。我不知道我做错了什么。在</p>
<p>这是我的代码:</p>
<pre><code>import urllib2
from bs4 import BeautifulSoup
url = 'http://m.imdb.com/feature/bornondate'
test_url = urllib2.urlopen(url)
readHtml = test_url.read()
test_url.close()
soup = BeautifulSoup(readHtml)
# Using it track the number of Actor
count = 0
# Fetching the value present within tag results
person = soup.findChildren('section', 'posters list')
# Changing the person into an iterator
iterperson = iter(person[0].findChildren('a'))
# Finding 'a' in iterperson. Every 'a' tag contains information of a person
for a in iterperson:
imgSource = a.find('img')['src'].split('._V1.')[0] + '._V1_SX214_AL_.jpg'
person = a.findChildren('div', 'label')
title = person[0].find('span', 'title').contents[0]
##profession = person[0].find('div', 'detail').contents[0].split(,)
##bestWork = person[0].find('div', 'detail').contents[1].split(,)
print '*******************************IMDB People Born Today***********************************'
# Printing the S.No of the person
print 'S.No. --> ',
count += 1
print count
# Printing the title/name of the person
print 'Title --> ' + title
# Printing the Image Source of the person
print 'Image Source --> ', imgSource
# Printing the Profession of the person
##print 'Profession --> ', profession
# Printing the Best work of the person
##print 'Best Work --> ', bestWork
</code></pre>
<p>目前没有打印出来。
还有,如果这是模糊的,你能解释一下如何做名人的名字,例如?在</p>
<p>下面是第一位名人的html代码,如果有帮助的话:</p>
^{pr2}$