Skip to main content

A small and simple HTML table parser not requiring any external dependency.

Project description


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.


pip install html-table-parser-python3

How to use

Example Usage:

import urllib.request
from pprint import pprint
from html_table_parser.parser 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)

def main():
    url = ''
    xhtml = url_get_contents(url).decode('utf-8')

    p = HTMLTableParser()

if __name__ == '__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']]]


There is also a command line interface which you can use directly to generate a CSV:

./html_table_converter -u -o metaltrain


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



Project details

Download files

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

Files for html-table-parser-python3, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size html_table_parser_python3-0.2.0-py3-none-any.whl (15.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size html-table-parser-python3-0.2.0.tar.gz (15.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page