Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

perl form filling

by PerlSufi (Friar)
on Apr 17, 2013 at 20:26 UTC ( [id://1029219]=perlquestion: print w/replies, xml ) Need Help??

PerlSufi has asked for the wisdom of the Perl Monks concerning the following question:

hello monks I am having an issue filling out a form with valid information. Here is my code:
#! /usr/bin/perl use Web::Scraper; use WWW::Mechanize; use WWW::Mechanize::FormFiller; use LWP::UserAgent; #This block of code follows from the CAPS homepage to the Account Inqu +iries link my $mech = WWW::Mechanize->new(); my $url = "http://caps.usps.gov/capshome.asp"; $mech->get($url); $mech->follow_link( url => 'https://caps.usps.gov/ssl_caps/caps_ai +.asp'); if ($mech->success()){ print "Successful Connection\n"; } else { print "Not a successful connection\n"; } #enter start and end date print "Enter Start date in the form of MMDDYY:\n"; my $start_date = <STDIN>; chomp; print "Please Enter an end date in the form of MMDDYY:\n"; my $end_date = <STDIN>; chomp; #This block of code is intended to fill in the required forms $mech->get("https://caps.usps.gov/ssl_caps/caps_ai.asp"); my $usr = "11111"; #not valid id for security purposes my $pw = "1111"; #not valid pw for security $mech->form_number(1); $mech->field( "capsn", $usr); $mech->form_number(2); $mech->field("capsp", $pw); $mech->form_number(3); $mech->field( "startdate", $start_date); $mech->form_number(4); $mech->field( "enddate", $end_date); $mech->click(); #print the content (for debugging) print $mech->content;
The message I get with the displayed content is that I did not enter a valid starting date, but I have. Any help is greatly appreciated! Love, PerlSufi

Replies are listed 'Best First'.
Re: perl form filling
by CountOrlok (Friar) on Apr 17, 2013 at 20:40 UTC
    The two chomp lines you have there, replace them with:
    chomp($start_date); chomp($end_date);
      Yes! I love you! My n00bness didn't allow me to see that PerlSufi

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-03-28 11:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found