Skip to main content

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

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

untable-0.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

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

Hashes for untable-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7824015f3a9a6371c18ab120e4636dc5758452b86ca855f5d217d277454418d7
MD5 4ca1a540806edf095ccdf1e1d702ebfc
BLAKE2b-256 0f11284b3534a368cdd086d25e7bd23da0413e79b758601b4ed4fe87e381d3dd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page