Getting WWW::Mechanize to submit a form
- From: Amer Neely <perl4hire@xxxxxxxxxxxxxx>
- Date: Sat, 15 Sep 2007 15:44:30 -0400
Apologies 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<br>\n" if $mech->success();
$mech->form($name);
die "Can't get the form name: ", $mech->response->status_line
unless $mech->success;
print "Found '$name'<br>\n" if $mech->success();
$mech->field('txtFirstName',$Firstname); # previously defined
$mech->field('txtLastName',$Lastname); # previously defined
print "Populated '$name'<br>\n" if $mech->success();
my $results = $mech->submit();
print "Submitted '$name'<br>\n" if $mech->success();
print "</body></html>\n";
-------------------------- 8< ---------------------------
When the script runs, it prints out everything as if there were no errors. But the programmer running the form at the remote site is saying nothing is coming through. I've tested a similar script myself, taking form data from a static HTML form, and posting it to another static HTML form on a different server, and it works fine.
Can anyone see anything wrong with this code that would cause it to fail? The form I'm trying to populate and submit is a .aspx document.
--
Amer Neely
w: www.webmechanic.softouch.on.ca/
Perl | MySQL programming for all data entry forms.
"Others make web sites. We make web sites work!"
.
- Follow-Ups:
- Re: Getting WWW::Mechanize to submit a form
- From: Mumia W.
- Re: Getting WWW::Mechanize to submit a form
- Prev by Date: Re: Help with Math::GMP compile on AIX 5.3
- Next by Date: Re: Getting WWW::Mechanize to submit a form
- Previous by thread: only want to install one module and the depended ones, but CPAN always install the whole Perl.
- Next by thread: Re: Getting WWW::Mechanize to submit a form
- Index(es):
Relevant Pages
|
|