Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import lxml.html
def get_incidents():
incidents = []
url = ""
tree = lxml.html.parse(url)
for inc in tree.xpath("//table[@class='report']"):
inc_keys = inc.xpath("tr/td[@class='c1']")
inc_keys = [key.text_content() for key in inc_keys]
inc_values = inc.xpath("tr/td[@class='c2']")
inc_values = [value.text_content() for value in inc_values]
incidents.append(dict(zip(inc_keys, inc_values)))
return incidents[1:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.