Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

License

Notifications You must be signed in to change notification settings

boazde/html-table-parser-python3

Open more actions menu
 
 

Repository files navigation

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 I use is part of python 3. Instead of installing this module, you can just copy the class located in parse.py into your own code.

How to use

Probably best shown by example using pyenv for convenience:

pyenv local
python ./example_of_usage.py

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']]]

CLI

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

./html_table_converter -u http://metal-train.de/index.php/fahrplan.html -o metaltrain

If you need help for the supported parameters append -h:

./html_table_converter -h

Tests

Sadly there are none. I'd really be interested in a PR since I don't know the python ecosystem well.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.