我试图让beautifulsoup一个URL工作,如下所示:BeautifulSoup类HTTPResponse有没有属性编码
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://proxies.org")
soup = BeautifulSoup(html.encode("utf-8"), "html.parser")
print(soup.find_all('a'))
但是,我得到一个错误:
File "c:\Python3\ProxyList.py", line 3, in <module>
html = urlopen("http://proxies.org").encode("utf-8")
AttributeError: 'HTTPResponse' object has no attribute 'encode'
知道为什么?难道是用urlopen函数做的吗?为什么需要utf-8?
有明确似乎与Python 3和BeautifulSoup4一定的差异,对于那些给出的例子(这似乎是过时或错误的现在)...
该结束了,这是解决方案需要 - http://stackoverflow.com/questions/32382686/unicodeencodeerror-charmap-codec-cant-encode-character-u2010-character-m –