Getting WWW::Mechanize to submit a form
am 15.09.2007 21:44:30 von Amer NeelyApologies if I upset someone by posting this here. I had no response in
comp.lang.perl.misc.
I'm trying to use this module to populate and submit a form on a remote
server, but *apparently* it is not doing either.
-------------------------- 8< ---------------------------
#! /usr/bin/perl
use strict;
use warnings;
use lib (
'/home/usr241/cgi-bin/PerlMods/WWW-Mechanize-1.18/lib',
'/home/usr241/cgi-bin/PerlMods/libwww-perl-5.808/lib',
'/home/usr241/cgi-bin/PerlMods/HTML-Parser-3.56/lib/'
);
use WWW::Mechanize;
use HTML::Form;
my $mech = WWW::Mechanize->new();
my $url = "http://xxx.xxx.xxx./form.aspx"; # edited
my $name="form1";
$mech->get( $url );
die "Can't even get the home page: ", $mech->response->status_line
unless $mech->success;
print "Found $url
\n" if $mech->success();
$mech->form($name);
die "Can't get the form name: ", $mech->response->status_line
unless $mech->success;
print "Found '$name'
\n" if $mech->success();
$mech->field('txtFirstName',$Firstname); # previously defined
$mech->field('txtLastName',$Lastname); # previously defined
print "Populated '$name'
\n" if $mech->success();
my $results = $mech->submit();
print "Submitted '$name'
\n" if $mech->success();
print "