This my Answer to the stackoverflow question: Extracting info from html using PHP(XPath), PHP/Python(Regexp) or Python(XPath)
If speed is a requirement have a look at lxml. lxml is a pythonic binding for the libxml2 and libxslt C libraries. Using the C libraries is much faster than any pure php or python version.
There are some impressive benchmarks from Ian Bicking:
I knew lxml was fast before I started these benchmarks, but I didn’t expect it to be quite this fast.