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 hashes)

Uploaded Python 3

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