Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

perl form filling

by PerlSufi (Friar)
on Apr 17, 2013 at 20:26 UTC ( #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

Comment on perl form filling
Download Code
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
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? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-10-22 01:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (112 votes), past polls