您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python和BeautifulSoup编码问题

Python和BeautifulSoup编码问题

你可以尝试:

r = urllib.urlopen('http://www.elnorte.ec/')
x = BeautifulSoup.BeautifulSoup(r.read)
r.close()

print x.prettify('latin-1')

我得到正确的输出。哦,在这种特殊情况下,您也可以x.__str__(encoding='latin1')

我猜这是因为内容在ISO-8859-1(5)中,并且Meta http-equiv内容类型错误显示为“ UTF-8”。

你能确认吗?

python 2022/1/1 18:38:40 有269人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶