已采纳回答 / 蚂蚁帅帅
正常情况下html.parser默认是具备的,出现这种错误,可以检查一下bs的版本和python的版本,是不是适配。在http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser这个链接可以看到,Python’s html.parser Not very lenient (before Python 2.7.3 or 3.2.2)请检查下Python的版本吧
2015-12-18
老师 cmd报错了
Command python setup.py egg_info failed with error code 1 in c:\users\yl\appdata
\local\temp\pip-build-yl\beautifulsoup4
Storing complete log in C:\Users\yl\pip\pip.log
Command python setup.py egg_info failed with error code 1 in c:\users\yl\appdata
\local\temp\pip-build-yl\beautifulsoup4
Storing complete log in C:\Users\yl\pip\pip.log
2015-12-18
对于Python 3.x,代码需要做相应改变:
import urllib.request
resp = urllib.request.urlopen('http://www.baidu.com')
print(resp.getcode())
import urllib.request
resp = urllib.request.urlopen('http://www.baidu.com')
print(resp.getcode())
2015-12-18