github.com/hoffmann Peter Hoffmann on Stackoverflow @peterhoffmann on twitter Peter Hoffmann on Facebook Contact me per email Subscribe to Atom Feed

Peter Hoffmann

Software Engineer
prev page next page

Extracting info from html using PHP(XPath), PHP/Python(Regexp) or Python(XPath)

Posted on October 12, 2009
#stackoverflow #python

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:

In Conclusion

I knew lxml was fast before I started these benchmarks, but I didn’t expect it to be quite this fast.

Parsing Results:

Parsing Resutls