A simple tool to parse HTML table to a 2d-array-like data structure
Project description
getable
A simple tool to parse HTML table to a 2d-array-like data structure.
Installation
pip install getable
Usage
Now we get a standard HTML table like below, let's see what we can do with getable.
House | Region | Seat | Words |
---|---|---|---|
Targaryen | Crownlands | Dragonstone | Fire and Blood |
Stark | North | Winterfell | Winter is Coming |
Lannister | Westerlands | Casterly Rock | Hear Me Roar |
Greyjoy | Iron Islands | Pyke | We Do Not Sow |
from getable import TableParser
source = """
<table id="standardTable">
<thead>
<tr><th>House</th><th>Region</th><th>Seat</th><th>Words</th></tr>
</thead>
<tbody>
<tr><td>Targaryen</td><td>Crownlands</td><td>Dragonstone</td><td>Fire and Blood</td></tr>
<tr><td>Stark</td><td>North</td><td>Winterfell</td><td>Winter is Coming</td></tr>
<tr><td>Lannister</td><td>Westerlands</td><td>Casterly Rock</td><td>Hear Me Roar</td></tr>
<tr><td>Greyjoy</td><td>Iron Islands</td><td>Pyke</td><td>We Do Not Sow</td></tr>
</tbody>
</table>
"""
table_parser = TableParser()
table = table_parser.parse(source=source, locator="#standardTable")
print(table.head) # House, Region, Seat, Words
print(table.head[0].text) # House
print(table.body)
"""
Targaryen, Crownlands, Dragonstone, Fire and Blood
Stark, North, Winterfell, Winter is Coming
Lannister, Westerlands, Casterly Rock, Hear Me Roar
Greyjoy, Iron Islands, Pyke, We Do Not Sow
"""
print(table.body[-1][-1].text) # We Do Not Sow
print(table[-1][-1].text) # We Do Not Sow
License
This project is licensed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
getable-0.1.1.tar.gz
(6.1 kB
view details)
Built Distribution
File details
Details for the file getable-0.1.1.tar.gz
.
File metadata
- Download URL: getable-0.1.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db989c997219a737587b376975f2fe6dd356e7788c7e03a1b0ef51665f4fa98b |
|
MD5 | ad70a2c5db95ef1a05290939d8723e60 |
|
BLAKE2b-256 | 3ccccff2f548424d5a08929ea8e0103f4c2b90088b22ce2db1b22eeaff46bef8 |
File details
Details for the file getable-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: getable-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80566e20d758149972d42a289231f0e336ac82a06a8bec10c3080772404a5364 |
|
MD5 | afd506d85e633cebc1bb2b9fd2b468fc |
|
BLAKE2b-256 | f115d122996f09f1ca7fb0ff7bdb4a3a3f6ebd5361f6dbd5d2df5ee8276b6872 |