python - lxml - how to get xpath of HtmlElement? -
using xml etree, it's possible do:
etree.getpath(element
how same thing, html instead of xml?
the _elementtree
has getpath
method:
in [17]: import lxml.html lh in [18]: content = '<root><div id="pgbrk" ......>....page break....</div></root>' in [19]: root = lh.fromstring(content) in [20]: tree = root.getroottree() in [21]: tree.getpath(root[0]) out[21]: '/html/body/root/div'
python html xml xpath lxml
No comments:
Post a Comment