This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tips:xpath [2015/09/24 09:45] – created scipio | tips:xpath [2015/09/24 11:12] (current) – scipio | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| With lxml and python | With lxml and python | ||
| + | |||
| + | < | ||
| + | sudo apt-get install libxml2-dev libxslt1-dev python-dev | ||
| + | pip install lxml | ||
| + | </ | ||
| + | |||
| print xpath of all elements | print xpath of all elements | ||
| Line 12: | Line 18: | ||
| doc=html.fromstring(htmltext) | doc=html.fromstring(htmltext) | ||
| - | #find_text = doc.xpath("// | ||
| tree=etree.ElementTree(doc) | tree=etree.ElementTree(doc) | ||
| for e in tree.iter(): | for e in tree.iter(): | ||