Skip to content

zhaoblake/getable

Repository files navigation

getable

Test Package version Supported Python versions

Parse HTML table to a 2d-array-like data structure.

Installation

pip install getable

Example

from getable import TableParser

html = """
<table id="table">
    <thead>
        <tr><th>Name</th><th>Age</th></tr>
    </thead>
    <tbody>
        <tr><td>Alpha</td><td>10</td></tr>
        <tr><td>Bravo</td><td>20</td></tr>
    </tbody>
</table>
"""
    
parser = TableParser()
table = parser.parse(source=html, locator="#table")
for row in table:
    for cell in row:
        print(cell.text)