Test:
Get values of all fields of a form, update the values and then print new values
Solution:
use warnings;
use WWW::Mechanize;
my $m = WWW::Mechanize->new();
$m->get("http://vienna.yapceurope.org/ye2007/search");
my $count = 1;
for my $form ($m->forms)
{
print "form $count fields are:\n";
$count++;
for ($form->param)
{
printf "%s - %s\n", $_, $form->value($_);
}
print "\n";
}
$m->submit_form(
form_number => 1,
fields => { name => 'honey', town => 'Delhi', country =>
'india', pm_group => 'Cam.pm'},
);
$count = 1;
print "After filling data to form\n";
for my $form ($m->forms)
{
print "form $count fields are:\n";
$count++;
for ($form->param)
{
printf "%s - %s\n", $_, $form->value($_);
}
print "\n";
}

No comments:
Post a Comment