Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Parse html tables using pandas
import pandas as pd
import requests
from lxml import etree
import urllib
url = ''
html = requests.get(url).content
html = etree.HTML(html)
tr_nodes = html.xpath('.//table[contains(.,"Name and Address of Beneficial Owner")]')
if len(tr_nodes)>0:
print("Found matching table")
table_data =etree.tostring(tr_nodes[0])
df = pd.read_html(table_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment