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.
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
2009-04-05 23:11:28
+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
2009-04-06 12:58:34
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
2009-04-06 13:21:13
+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
2009-04-06 18:19:28