in reply to WWW::Mechanize problem

May be you inspect wrong form? Try to find needed form by name and after that use field() property.

Replies are listed 'Best First'.
Re^2: WWW::Mechanize problem
by SavagePerl (Novice) on May 29, 2008 at 02:27 UTC
    OK, here is exactly what Im trying to do. Im trying to make the program ask the user for a zip code they want to do a search on to find all the nearest insurance agencies in the area. Here is the site I am trying to use http://www.unitrinspecialty.com/us/locator/. Here is the code so far..
    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_number(1); $browser->field("zipCode", $module_name); $browser->click();

      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!
        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();