in reply to Re: how to submit html form?
in thread how to submit html form?

I hear a lot about WWW::Mechanize, but I don't quite understand the point of what it allows you to do. I've read the docs, but not sure of it's real life application. Can someone give me a quick synopsis? Thanks.


—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Replies are listed 'Best First'.
Re^3: how to submit html form?
by Popcorn Dave (Abbot) on Nov 27, 2005 at 21:31 UTC
    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.
Re^3: how to submit html form?
by davido (Cardinal) on Nov 28, 2005 at 04:53 UTC

    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.


    Dave