Can someone point me to an HTML parser that turns an HTML document into a nested data structure like what I sketched out below? I'm sick of having to jump through hoops to collect the text of a link. I know there's something similar for XML because I heard about it at EuroPython. Stop me before I write my own! Must work or be makable to work in Python 1.5.2. Offer not valid in "Mirror, Mirror" universe.
Sorry, no spectacular thing to show you today. I've got only one of the three things working that I wanted to have, and (sad to say) it's not the one that hits people in the gut and makes them think This Is Important, insofar as any of them do that.
This is an HTML document.
->
["This is an", [TAG name='a' attrs={href: 'http://www.w3.org/MarkUp/', title: "Brought to you by HTMLCorp"} child=[TAG name='b' child=["HTML"]], "document"], "."]
Update, much later: I wrote Beautiful Soup because I wasn't happy with any existing parser.

![5 comments [Comments]](/nb/assets/comments.png)
Posted by Nick Moffitt at Mon Mar 29 2004 11:43
Posted by Leonard at Mon Mar 29 2004 12:22
Posted by Fredrik at Mon Mar 29 2004 12:27
Posted by Aaron Swartz at Mon Mar 29 2004 12:36
Posted by Leonard at Mon Mar 29 2004 13:07