pat_mc has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Monks -

With extremely limited www experience in Perl under my belt I was wondering if there is an efficient way to fill free-text entry fields on HTML pages with a perl script and subsequently perform an action such as a form submit.

I appreciate your help in this matter!

Thanks and regards -

Pat

Update:
Not sure if it is me but there seem to be problems with WWW::Mechanize -> find_all_inputs() and some other methods.

Can anybody please advise based on my code snippet in response to ikegami?
Thanks!

Replies are listed 'Best First'.
Re: Script-based filling of free-text entries on HTML pages
by ikegami (Patriarch) on Aug 12, 2008 at 15:24 UTC
      Thanks, ikegami.

      I tried WWW:Mechanize but could not get the extraction of inputs or images to work. I used the following code:
      #! /usr/bin/perl -w use strict; use WWW::Mechanize; my $mech = WWW::Mechanize -> new(); $mech -> get( 'http://www.merriam-webster.com/' ); for my $input ( $mech -> find_all_inputs() ) { printf $input -> name(), $input -> type(), "\n"; } for my $image ( $mech -> find_all_images() ) { printf "%-100s %s\n", $image -> image(), image -> tag(); }


      I get error messages of the type
      Can't locate object method "find_all_inputs" via package "WWW::Mechanize" at test.pl line ...
      Any ideas why this is not working?

      Thanks and regards -

      Pat
Re: Script-based filling of free-text entries on HTML pages
by dwm042 (Priest) on Aug 12, 2008 at 15:49 UTC
      Thanks for your suggestion, dwm042. Incidentally, I have a copy of the book you mention but have to admit I am only finding it moderately helpful. To the uninitiated it appears to be little more than a cookbook ... what I would prefer is a book that actually explains things (along the lines of O'Reilley's classic 'Learning Perl').

      Thanks for your reply, anyway!

      Pat

        I agree with you, and the best way is really just to dive in to the WWW::Mechanize documentation, which is very thorough and very readable, even for the uninitiated. Make lots of test scripts with the various form-filling functions - there are several ways to do it and find out what you're comfortable with.

        Also look at the Forms subclass and explore the methods there. Just practice!