use WWW::Mechanize; use strict; my $username = "admin"; my $password = "welcome1"; my $outpath = "/home/data/output"; my $fromday = 7; my $url = "https://www.myreports.com/tax_report.php"; my $name = "tax_report"; my $outfile = "$outpath/$name.html"; my $mech = WWW::Mechanize->new(noproxy =>'0'); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year += 1900; $mon++; # since it will start from 0 $mday--; # yesterdays date (to day) $fromday = $mday - $days; #(from day) #Create URL extension for generating report with previous date my $dt_range = "?dc_range=Y&dc_date1=$mon%2F$fromday%2F$year&dc_date2=$mon%2F$mday%2F$year"; my $url = $url . $dt_range; $mech->get($url); $mech->field(login => "$username"); $mech->field(passwd => "$password"); $mech->click_button(value=>"Login now"); my $response = $mech->content(); print "Generating report: $name...\n"; open (OUT, ">>$outfile")|| die "Cannot create report file $outfile"; print OUT "$response"; close OUT;