Created
May 23, 2019 19:24
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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