Skip to main content

html-table-parser-python3

This module consists of just one small class. Its purpose is to parse HTML tables without help of external modules. Everything used is part of python 3.

Installation

pip install html-table-parser-python3

How to use

Example Usage:

import urllib.request
from pprint import pprint
from html_table_parser_python3 import HTMLTableParser


def url_get_contents(url):
    """ Opens a website and read its binary contents (HTTP Response Body) """
    req = urllib.request.Request(url=url)
    f = urllib.request.urlopen(req)
    return f.read()


def main():
    url = 'http://www.twitter.com'
    xhtml = url_get_contents(url).decode('utf-8')

    p = HTMLTableParser()
    p.feed(xhtml)
    pprint(p.tables)


if __name__ == '__main__':
    main()

The parser returns a nested lists of tables containing rows containing cells as strings. Tags in cells are stripped and the tags text content is joined. The console output for parsing all tables on the twitter home page looks like this:

>>> 
[[['', 'Anmelden']],
 [['Land', 'Code', 'Für Kunden von'],
  ['Vereinigte Staaten', '40404', '(beliebig)'],
  ['Kanada', '21212', '(beliebig)'],
  ...
  ['3424486444', 'Vodafone'],
  ['Zeige SMS-Kurzwahlen für andere Länder']]]

Credit

All Credit goes to Josua Schmid (schmijos). This is all his work, I just uploaded it to PyPi. Original repository can be found at:

https://github.com/schmijos/html-table-parser-python3

License

GNU GPL v3

Metadata

Release files for html-table-parser-python3 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for html-table-parser-python3 0.1.3
File Size Uploaded
html-table-parser-python3-0.1.3.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for html-table-parser-python3 0.1.3
File Interpreter ABI Platform
html_table_parser_python3-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 kB

Release files / html-table-parser-python3-0.1.3.tar.gz

Download URL html-table-parser-python3-0.1.3.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
621b7beec3d168dba87e9da064096fde2a7d62f92b7de3449f0c0727a88ee417
BLAKE2b-256 checksum
How to use checksums
1f8fe5990b18b02f2e0febc87dc2bdba49c6b93ce8ae520598f9db69f3ff0ab2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release files / html_table_parser_python3-0.1.3-py3-none-any.whl

Download URL html_table_parser_python3-0.1.3-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6528bc49abf399320f92a230cbd351fe663f97b74e52095ef7f905feb49bb684
BLAKE2b-256 checksum
How to use checksums
e367966e5b64c87b275c94dc9e1bb34ca41db926cca534a12d33aa37aa83b3e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release history Release notifications | RSS feed

0.3.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page