[英]Removing BOM characters from <HtmlElement> Python
I am trying to load the html markup from a URL this way, and then run some xpath queries, but the page source is loaded with BOM, how to I remove them before I run the xpath? 我正在尝试以这种方式从URL加载html标记,然后运行一些xpath查询,但是页面源已加载BOM,在运行xpath之前如何删除它们?
session = requests.Session()
page = session.get(url)
page_data = lxml.html.fromstring(page.text)
Output: 输出:
u'Re\ufeffverse \ufeffFleece \ufeffHoo\ufeffded S\ufeffwea\ufefftshi\ufeffrt'
session = requests.Session()
page=session.get(url)
page_data = lxml.html.fromstring(page.text)
float=lxml.html.tostring(page_data).replace('', '')
page_data = lxml.html.fromstring(float)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.