No project description provided
Project description
Untable
A lightweight Python module to scrape HTML tables.
>>> import untable
>>> import requests
>>> from pprint import pprint
>>> html = requests.get("https://www.w3schools.com/html/html_tables.asp").text
>>> data = untable.multi(html)
>>> pprint(data)
[{'Company': 'Alfreds Futterkiste',
'Contact': 'Maria Anders',
'Country': 'Germany'},
{'Company': 'Centro comercial Moctezuma',
'Contact': 'Francisco Chang',
'Country': 'Mexico'},
{'Company': 'Ernst Handel', 'Contact': 'Roland Mendel', 'Country': 'Austria'},
{'Company': 'Island Trading', 'Contact': 'Helen Bennett', 'Country': 'UK'},
{'Company': 'Laughing Bacchus Winecellars',
'Contact': 'Yoshi Tannamuri',
'Country': 'Canada'},
{'Company': 'Magazzini Alimentari Riuniti',
'Contact': 'Giovanni Rovelli',
'Country': 'Italy'}]
Installation
pip install untable
Usage
Untable can extract data from two types of tables: single and multi-entity.
Multi-entity tables are like the one in the example above, where a table carries information for multiple items. They have headers on their first row and data on the others. Use untable.multi on them.
Single entity tables carry data from only one entity, in a form-like structure. They can have headers and data on the same row. For example:
| Name: | Ada Lovelace |
| DOB: | 12-10-1815 |
| Profession: | Programmer |
Use untable.single on this type of table. You may need to play with the threshold parameter to get the extraction right.
Read untable.py to find more information.
Contribute
PRs welcome!
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file untable-0.1-py3-none-any.whl.
File metadata
- Download URL: untable-0.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7824015f3a9a6371c18ab120e4636dc5758452b86ca855f5d217d277454418d7
|
|
| MD5 |
4ca1a540806edf095ccdf1e1d702ebfc
|
|
| BLAKE2b-256 |
0f11284b3534a368cdd086d25e7bd23da0413e79b758601b4ed4fe87e381d3dd
|