【发布时间】:2011-02-09 00:47:37
【问题描述】:
我正在尝试使用 BeautifulSoup 来解析一些网页,每当我使用 findAll 时它总是返回 null,即使我可以访问 soup.title 之类的东西也很好。
我现在正在尝试使用this link 进行解析,这就是我尝试使用它时得到的结果:
>>> site = urllib2.urlopen('http://www.newegg.com/Product/ProductList.aspx?Submit=ENE&IsNodeId=1&Description=nvidia%20gtx%20560%20ti&bop=And&Order=PRICE&PageSize=20')
>>> soup = BeautifulSoup(site)
>>> soup.title
<title>Newegg.com - nvidia gtx 560 ti</title>
>>> soup.findAll('title')
Null
>>>
有谁知道它为什么这样做?我正在使用 BeautifulSoup 2.1.1
【问题讨论】:
-
如果还可以,请跳到scrapy。它更强大,仍然受支持
-
您的 url 链接给了我格式错误的开始标签错误。我在其他网站上试过代码,一切都很好。
-
使用 BeautifulSoup 3.2.0 和示例中的 URL 为我工作。
标签: python beautifulsoup