Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: WWW::Mechanize problem

by jasonk (Parson)
on May 29, 2008 at 02:31 UTC ( [id://688950]=note: print w/replies, xml ) Need Help??


in reply to Re^2: WWW::Mechanize problem
in thread WWW::Mechanize problem

Go to the website in a browser. Select 'View Source'. Search for the word 'form'. Discover that form #1 is the search box in the upper right hand corner, and you are attempting to set non-existent fields in the wrong form.

After that, either try $mech->form_number(2), or better yet $mech->form_name( 'zipForm' ) or even $mech->form_with_fields( 'zipCode' ).


www.jasonkohles.com
We're not surrounded, we're in a target-rich environment!

Replies are listed 'Best First'.
Re^4: WWW::Mechanize problem
by SavagePerl (Novice) on May 29, 2008 at 03:36 UTC
    Awesome. Thanks man. Now I got this lol... Input 'zipCode' has maxlength '5' at C:/Perl/lib/WWW/Mechanize.pm line 1247 Here is the code:
    use strict; use warnings; print "What zip code? \n"; my $module_name = <STDIN> or die "Must specify module name on command line"; use WWW::Mechanize; my $browser = WWW::Mechanize->new(); $browser->get("http://www.unitrinspecialty.com/us/locator/"); $browser->form_name('zipForm'); $browser->field("zipCode", $module_name); $browser->click();
      "12345\n" is 6 characters. chomp

      You mentioned the command line in your error message. Perhaps you want to use @ARGV instead of <STDIN>?

      use strict; use warnings; use WWW::Mechanize qw( ); use File::Basename qw( basename ); sub usage { my $prog = basename($0); print STDERR ("usage: $prog {zipcode}\n"); exit(1); } my ($zip_code) = @ARGV; defined($zip_code) or usage(); my $browser = WWW::Mechanize->new(); $browser->get("http://www.unitrinspecialty.com/us/locator/"); $browser->form_name('zipForm'); $browser->field("zipCode", $module_name); $browser->click();

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://688950]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-19 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found