Archive for September, 2008

Sep 27 2008

Parsing Tables With Beautiful Soup

Published by tim under coding

Just a quick snippet, since it is obvious after writing it but was not obvious while searching for it:

html = file("whatever.html")
soup = BeautifulSoup(html)
t = soup.find(id=label)
dat = [ map(str, row.findAll("td")) for row in t.findAll("tr") ]

… or, map a different function is you need to further parse the individual table comments. At any rate, with Beautiful [...]

One response so far