Perl and LWP
explains how to write programs that browse the Web, using the excellent Library for the World Wide Web or LWP. It is aimed at developers who already know both Perl and HTML, although you don't need to be an expert in either.
The fascination of this topic is that it makes you see the Web in a different way, not as a set of pages for users to browse, but as a huge database for your programs to explore. The most robust technique for querying Web sites programmatically is through XML Web Services, but this approach is in its infancy. LWP takes a different route, called screen-scraping. In essence, your Perl code pretends to be a browser and grabs HTML for processing. Using LWP you could write a command-line program to search your favourite auction site, fetch news headlines, or check multiple retail sites for the best prices. As the author acknowledges, the problem with screen-scraping is its brittleness: if the target Web site adopts a new look, it breaks your code. There are also interesting fair usage issues. Even so, it's a powerful technique with many possible applications. This clear and concise guide comes complete with typically terse Perl code examples. Topics include LWP basics, posting form data, processing results with regular expressions, using trees to process HTML, imitating different browser types, and supporting cookies programmatically. An appendix offers handy information like HTTP status codes, character tables, and MIME types. LWP is large, but while this title does not attempt to cover all the modules, it does provide all you need to start coding your own Web-mining programs.--Tim Anderson
Salted with plenty of examples, the book covers the whole process of navigating HTTP, downloading content, and parsing it into something usable. -- Rick Wayne, Software Development, September 2002
Solid, no-nonsense book that will teach you how to do screen-scraping using Perl. -- MIR, slashdot.org, August 19, 2002
The indispensable guide to learning LWP and using it effectively. -- Netsurfer Digest, Feb 14, 2003