views:

1209

answers:

5

I want to fill in a web form with Perl. I am having trouble finding out the correct syntax to accomplish this. As in, how do I go to the URL, select the form, fill in the form, and then press enter to be sure it has been submitted? Any examples would be great. Thanks.

+11  A: 

Something like WWW::Mechanize::FormFiller?

Turnor
A: 

Request the form's action URL with Net::HTTP or something (can't recall the exact module), and include the forms fields as a GET/POST parameter (whichever the form calls for).

Charlie Somerville
+4  A: 

WWW::Mechanize and its friends are the way to go. There are several examples in Spidering Hacks, but you'll also find plenty more by googling for the module name.

Good luck, :)

brian d foy
A: 

HTML::Form works nicely, too.

The synopsis of the module is an excellent example:

 use HTML::Form;
 $form = HTML::Form->parse($html, $base_uri);
 $form->value(query => "Perl");

 use LWP::UserAgent;
 $ua = LWP::UserAgent->new;
 $response = $ua->request($form->click);
MaxVT
+2  A: 

Start with WWW::Mechanize::Shell:

perl -MWWW::Mechanize::Shell -e shell
get http://some/page
fillout
...
submit

Afterwards, type "script", and save generated code as something.pl - and that's about it. It's done.

depesz