最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

解析html报错:lxml.etree.XMLSyntaxError: Input is not proper UTF-8, indicate encoding !

常识 admin 39浏览 0评论

解析html报错:lxml.etree.XMLSyntaxError: Input is not proper UTF-8, indicate encoding !

from lxml import etree
doc = etree.parse('1.html') 

报错lxml.etree.XMLSyntaxError: Input is not proper UTF-8, indicate encoding !

 

把代码修改一下即可:

par = etree.HTMLParser(encoding="utf-8")
doc = etree.parse('1.html', parser=par)

解析html报错:lxml.etree.XMLSyntaxError: Input is not proper UTF-8, indicate encoding !

from lxml import etree
doc = etree.parse('1.html') 

报错lxml.etree.XMLSyntaxError: Input is not proper UTF-8, indicate encoding !

 

把代码修改一下即可:

par = etree.HTMLParser(encoding="utf-8")
doc = etree.parse('1.html', parser=par)
发布评论

评论列表 (0)

  1. 暂无评论