【发布时间】:2011-04-26 22:28:08
【问题描述】:
我正在尝试解析http://www.ted.com/talks 页面中的所有谈话名称。使用 BeautifulSoup,这就是我所拥有的:
import urllib2
from BeautifulSoup import BeautifulSoup
page = urllib2.urlopen("http://www.ted.com/talks")
soup = BeautifulSoup(page)
link = soup.findAll(lambda tag: tag.name == 'a' and tag.findParent('dt', 'thumbnail'))
for anchor in link.findAll('a', title = True):
print anchor['title']
最初的“链接”显示了一个很好的数组,其中包含八个视频块。然后我尝试通过这个并取出标签中的标题,使用上面的代码,这给了我以下错误:
for anchor in link.findAll('a', title=True):
AttributeError: 'ResultSet' object has no attribute 'findAll'
我做错了什么?
【问题讨论】:
标签: python beautifulsoup