#! /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 Inquiries 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 = ; chomp; print "Please Enter an end date in the form of MMDDYY:\n"; my $end_date = ; 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;