perl_monster has asked for the wisdom of the Perl Monks concerning the following question:
I have a simple requirement of screen scraping a web-page and direct the HTML response to an output file. The URL will however redirect to an authentication (Login) page with form base authentication (no javascript) and upon authentication the report I am trying to view would show up. Interestingly, my code is working just fine in a Windows machine, however the same code below is not working in AIX machine and it looks like the click_button() function call does nothing. I have tried click(), submit(), but none is working so instead of getting the actual report all I get is the logon screen in the HTML output file. Any ideas, what can be wrong?
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(t +ime); $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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WWW::Mechanize click_button() not working in AIX
by kcott (Archbishop) on Jul 10, 2012 at 16:44 UTC | |
by perl_monster (Novice) on Jul 10, 2012 at 17:08 UTC | |
|
Re: WWW::Mechanize click_button() not working in AIX
by Corion (Patriarch) on Jul 10, 2012 at 16:44 UTC | |
|
Re: WWW::Mechanize click_button() not working in AIX
by onelesd (Pilgrim) on Jul 10, 2012 at 17:34 UTC | |
by perl_monster (Novice) on Jul 10, 2012 at 18:01 UTC | |
by onelesd (Pilgrim) on Jul 10, 2012 at 21:01 UTC | |
by perl_monster (Novice) on Jul 10, 2012 at 21:31 UTC | |
by onelesd (Pilgrim) on Jul 10, 2012 at 21:45 UTC | |
|