已采納回答 / 螞蟻帥帥
正常情況下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