BS4:从BeautifulSoup对象获取lxml etree

问题描述 投票:0回答:1

如果我将 BeautifulSoup4 与

lxml
解析器一起使用,如何从 BeautifulSoup 对象获取 lxml etree 对象?

我会用它通过 XPath 查找元素。 BeautifulSoup4 本身不支持 XPath

web-scraping beautifulsoup lxml
1个回答
0
投票
lxml_root = etree.fromstring(str(raw_soup).encode())
© www.soinside.com 2019 - 2024. All rights reserved.