Skip to content

Simple script to convert html table to a python list of 2 dimensions, split rowspan and colspan

Notifications You must be signed in to change notification settings

4sushi/htmlParse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

HtmlParse

Description

Simple library to parse HTML file. Only one method, to convert html table to a python list of 2 dimensions (exemple : [[1,2,3],[1,2,3]]).

Python version

Python 2

Examples 1

The HTML table :

1 2
a b
html = """
<table>
    <tr>
        <td>1</td>
        <td>2</td>
    </tr>
    <tr>
        <td>a</td>
        <td>b</td>
    </tr>
</table>
"""
list_2d = htmlParse.table_to_list(html)
print(list_2d)

Output:

['1', '2'], ['a', 'b']

Examples 2

1 2 3 4
a b
c
html = """
<table>
    <tr>
        <td>1</td>
        <td rowspan=3 colspan=2>2</td>
        <td rowspan=3 colspan=2>3</td>
        <td>4</td>
    </tr>
    <tr>
        <td rowspan=2>a</td>
        <td>b</td>
    </tr>
    <tr>
        <td>c</td>
    </tr>
</table>
"""
list_2d = htmlParse.table_to_list(html)
print(list_2d)

Output:

[['1', '2', '2', '3', '3', '4'], ['a', '2', '2', '3', '3', 'b'], ['a', '2', '2', '3', '3', 'c']]

About

Simple script to convert html table to a python list of 2 dimensions, split rowspan and colspan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages