Well I had a task at work to get the mileage from two of our offices to a bunch of cities to see who was closer. Using WWW::Mechanize I went to one website to grab the zipcodes of all the cities. I did have to write a wrapper script to sleep for a bit as it only allowed me to look up 6 zip codes at a time though.
Next I took that list, and plugged it in to MapQuest and scraped for the distances.Needless to say, without WWW::Mechanize it would have taken me hours to do this by hand, while it took mere minutes to have the computer do it.
There is a great joy in writing something automated, going for a quick break, and coming back to find all your work done. :)
Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.
| [reply] |
WWW::Mechanize is a subclass of LWP::UserAgent, so it comes with all the functionality of UserAgent, plus its own additional functionality. What it is good for is acting like a web browser, while providing easy methods of automating many things that a web browser could do. This includes following links, handling forms, submitting forms, and so on.
The WWW::Mechanize documentation has some examples, but to me it made more sense once I dove into starting to use it. Think of a simple task you would like to automate that involves WWW screen scraping. Then sit down with the WWW::Mechanize docs, and figure out how you're going to accomplish this task using WWW::Mechanize (keeping in mind that it's a proper subclass of LWP::UserAgent). Fiddle and tweak, and eventually you'll figure out why it's useful.
| [reply] |