Skip to content Skip to sidebar Skip to footer

Html Table To List Parsing - Monkey Wrench For Both Xml And Lxml

I read the answers to Parse HTML table to Python list? and tried to use the ideas to read/process my local html downloaded from a web site (the files contain one table and start wi

Solution 1:

While waiting for some help showing how to do this in a 'Pythonic way', I came up with an easy brute force method:

With the string s set to the 2nd option, with the given <thead> and <tbody> labels, apply the following code:

s = ''.join(s.split('<tbody>'))
s = ''.join(s.split('</tbody>'))
s = ''.join(s.split('<thead>'))
s = ''.join(s.split('</thead>'))

Post a Comment for "Html Table To List Parsing - Monkey Wrench For Both Xml And Lxml"