
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
html-table-extractor
Advanced tools
HTML Table Extractor is a python library that uses Beautiful Soup to extract data from complicated and messy html table
pip install 'beautifulsoup4==4.5.3'
pip install html-table-extractor
1 | 2 |
3 | 4 |
from html_table_extractor.extractor import Extractor
table_doc = """
<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>
"""
extractor = Extractor(table_doc)
extractor.parse()
extractor.return_list()
It will print out:
[[u'1', u'2'], [u'3', u'4']]
1 | 2 |
3 | 4 |
from html_table_extractor.extractor import Extractor
table_doc = """
<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>
"""
extractor = Extractor(table_doc, transformer=int)
extractor.parse()
extractor.return_list()
It will print out:
[[1, 2], [3, 4]]
1 | 2 |
3 | 4 |
from html_table_extractor.extractor import Extractor
from bs4 import BeautifulSoup
table_doc = """
<html><table id='wanted'><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table><table id='unwanted'><tr><td>not wanted</td></tr></table></html>
"""
soup = BeautifulSoup(table_doc, 'html.parser')
extractor = Extractor(soup, id_='wanted')
extractor.parse()
extractor.return_list()
It will print out:
[[u'1', u'2'], [u'3', u'4']]
1 | 2 | 3 |
4 | ||
5 |
from html_table_extractor.extractor import Extractor
table_doc = """
<table>
<tr>
<td rowspan=2>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td colspan=2>4</td>
</tr>
<tr>
<td colspan=3>5</td>
</tr>
</table>
"""
extractor = Extractor(table_doc)
extractor.parse()
extractor.return_list()
It will print out:
[[u'1', u'2', u'3'], [u'1', u'4', u'4'], [u'5', u'5', u'5']]
1 | 2 | 3 |
4 | ||
5 |
from html_table_extractor.extractor import Extractor
table_doc = """
<table>
<tr>
<td rowspan=2>1</td>
<td>2</td>
<td rowspan=3>3</td>
</tr>
<tr>
<td colspan=2>4</td>
</tr>
<tr>
<td colspan=2>5</td>
</tr>
</table>
"""
extractor = Extractor(table_doc)
extractor.parse()
extractor.return_list()
It will print out:
[[u'1', u'2', u'3'], [u'1', u'4', u'3'], [u'5', u'5', u'3']]
1 | 2 |
3 | 4 |
from html_table_extractor.extractor import Extractor
table_doc = """
<table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>
"""
extractor = Extractor(table_doc).parse()
extractor.write_to_csv(path='.')
It will write to a given path and create a new csv file called output.csv
:
1,2
3,4
If something is not working correctly, or if you have any suggestion on improvements, report it here
Copyright (c) 2017 Justin Li. Released under the MIT License
Third-party copyright in this distribution is noted where applicable.
FAQs
A python library for extracting data from html table
We found that html-table-extractor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.