domingo, 3 de mayo de 2015

Testing XPaths on HTML with lxml

An example of how to test XPath expressions on Python using lxml library:
from lxml.html.soupparser import fromstring

root = fromstring( open('bla.html').read() )
nodes = root.xpath('//tr[2]/td[2]/text()')
print nodes[0].strip()
  1. BeautifulSoup Parser
  2. Python extensions for XPath and XSLT

No hay comentarios:

Publicar un comentario