Skip to content

Instantly share code, notes, and snippets.

@maik-s
Created May 23, 2019 19:24
Show Gist options
  • Save maik-s/f8c65295d7e6efe3df3c052b15fd8349 to your computer and use it in GitHub Desktop.
Save maik-s/f8c65295d7e6efe3df3c052b15fd8349 to your computer and use it in GitHub Desktop.
Simple gist to demonstrate how to use lxml for HTML5 to find elements with xpath.
#!/bin/python3
from lxml import etree
filename = "html5file.html"
parser = etree.HTMLParser(remove_blank_text=True)
tree = etree.parse(filename, parser)
elem = tree.xpath('/html/head')
print (elem)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment