Parsing HTML in Python
http://www.xmlhack.com/read.php?item=1392 http://sourceforge.net/projects/pirxx/
http://pyxml.sourceforge.net/topics/
I don't have much experience with python, but I have used Xerces (from the Apache foundation) in the past and found it to be very useful. The learning curve isn't bad either, though I'm not coming from a python perspective. I suggest you consider it though. (The first two links I've included discuss python interfaces to Xerces and the last one is the first google hit on "python xml").
You can install lxml and many other python modules easily and seamlessly on the Mac (OS X) using Pallet, which is the MacPorts official GUI
The module name is py27-lxml. Easy as 1,2,3.
Perhaps µTidylib will meet your needs?
Python has a native HTML parser, however the Tidy wrapper Nick suggested would probably be a solid choice as well. Tidy is a very common library, (written in C is it?)