> When I need to extract data from HTML I use XPath. But to do so I have to use the combination of following tools
I just use lxml.html (handles 99.999% of the HTML out there, add beautifulsoup's UnicodeDammit[0] for wonky encodings) and then use lxml's built-in xpath support on top of that.
Plus extra bonus, if the datamining paths are simple enough you can use CSS queries instead of XPath.
Thanks for pointing this out. I forgot to precise that I am using XPath on Unix/Cygwin command line or in Shell scripts. Here an example of extracting the Hacker News title;url;points;user data:
Could you put some newlines in that? For some reason, my browser (IE9) is rendering that construct as a VERY long line and extending the page to match it. (no code-specific scroll-bar for me)
I just use lxml.html (handles 99.999% of the HTML out there, add beautifulsoup's UnicodeDammit[0] for wonky encodings) and then use lxml's built-in xpath support on top of that.
Plus extra bonus, if the datamining paths are simple enough you can use CSS queries instead of XPath.
[0] http://lxml.de/elementsoup.html#using-only-the-encoding-dete...