嗨,我发现上面的错误。为什么会突然出现,我错过了什么,我该如何克服?谢谢
try:
import urllib.request as urllib2
except ImportError:
import urllib2
from html2text import html2text
sock = html2text(urllib2.urlopen('http://www.example.com'))
htmlSource = sock.read()
sock.close()
print (htmlSource)
我在Windows7操作系统上运行Idle3.4.3。
html2text
期望传入的HTML代码是字符串-读取响应:它打印:
Replace是字符串的属性,您有一个fileobject
是的。
这个没问题。
输出
我想我找到了Python3.4的解决方案。我刚把源代码解码成UTF-8,它成功了。
输出
相关问题 更多 >
编程相关推荐