in reply to how to submit html form?

It's pretty simple with WWW::Mechanize. That module offers a suite of form methods, and as for submitting button clicks, there are the submit() and click() methods (among others). Reading hidden fields is not a problem. Hidden fields are only hidden by browsers that choose not to render them (which is basically all browers), but there's no reason your script shouldn't have access to them. They're included in the HTML as you get it from the server.


Dave

Replies are listed 'Best First'.
Re^2: how to submit html form?
by bradcathey (Prior) on Nov 27, 2005 at 21:04 UTC

    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
      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.

      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