tips:xpath

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tips:xpath [2015/09/24 09:45] – created scipiotips:xpath [2015/09/24 11:12] (current) scipio
Line 4: Line 4:
  
 With lxml and python With lxml and python
 +
 +<code>
 +sudo apt-get install libxml2-dev libxslt1-dev python-dev
 +pip install lxml
 +</code>
 +
  
 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("//text()") 
 tree=etree.ElementTree(doc) tree=etree.ElementTree(doc)
 for e in tree.iter(): for e in tree.iter():
  • tips/xpath.1443080741.txt.gz
  • Last modified: 2015/09/24 09:45
  • by scipio