我爬到以下页面:beautifulsoup 4:分段故障(核心转储)
http://www.nasa.gov/topics/earth/features/plains-tornadoes-20120417.html
但我得到分割故障(核心倾倒)时调用:BeautifulSoup(page_html),其中page_html是从内容请求库。这是BeautifulSoup的错误吗?有没有办法解决这个问题?即使像try ...一样的方法可以帮助我运行代码。提前致谢。
的代码如下:
import requests
from bs4 import BeautifulSoup
toy_url = 'http://www.nasa.gov/topics/earth/features/plains-tornadoes-20120417.html'
res = requests.get(toy_url,headers={"USER-Agent":"Firefox/12.0"})
page = res.content
soup = BeautifulSoup(page)
请显示您使用的代码,以便它可以被复制(我无法使用urllib2和BeautifulSoup复制此代码)。 –
@DavidRobinson代码现在被添加。感谢您的询问。 – Taosof
安装'lxml'。 py2.7默认的HTML解析器不会解析这个页面,因为标签错误... BTW,py3.2可以正常工作。 (不能使段错误) – JBernardo