Thank you for the tips.
To start with, I hardcoded the URL to see if it works:
my $homepage = "https://xxx/gamma/z2xcmnmainam/index";
$m->get($homepage);
print $m->content();
This worked and I'm able to see the homepage!
Now, I need to make it more generic for it to be able to work with any URL.
I tried to use WWW::Mechanize::Plugin::FollowMetaRedirect
$m->get($url);
$m->follow_meta_redirect;
But while trying to run, it gives me this error:
Can't locate WWW/Mechanize/Pluggable.pm in @INC (@INC contains: C:/Dwimperl/perl
/site/lib C:/Dwimperl/perl/vendor/lib C:/Dwimperl/perl/lib .)
Could you please suggest how to fix this error?
I also tried to parse the HTML for URL:
use WWW::Mechanize;
#use WWW::Mechanize::Plugin::FollowMetaRedirect;
use strict;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
my $m = WWW::Mechanize->new(autocheck => 1);
$m->add_header( "Connection" => "keep-alive", "Keep-Alive" => "115
+");
my $url="https://rp6.bench.ehc.adp.com/siteminderagent/forms/LSPRH3/lo
+gin.fcc?TYPE=33554433&REALMOID=06-7d0449cd-e3ed-10fb-9f50-8498490a0cb
+3&GUID=&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=-SM-s2uV8pMx7pQ%2byUUrf
+iIGkme9FfRRMzZ8AkgpHMTZaaKvrgCvd%2fA99CuE2IG3sVvp&TARGET=-SM-https%3a
+%2f%2frp6%2ebench%2eehc%2eadp%2ecom%2findex_lsprh%2ehtml";
print "$INC{'WWW/Mechanize.pm'}\n";
$m->get($url);
#$m->follow_meta_redirect;
$m->success or die "login GET fail";
my $user='bdos0101-b01';
my $pass='bench_0';
my $login = $m->form_name("loginform");
$m->forms;
$m->form_name('loginform');
$login->value('USER' => $user);
$login->value('password' => $pass);
$m->submit();
$m->success or die "login POST fail";
print "Login done\n";
#print $response->content();
if ($m =~ m!<meta\s+http-equiv=['"]refresh["']\s+content="\d+;([^"]+)"
+!si) {
warn "Refresh found (-> $1), following";
my $target = $1;
$m->get($target);
};
print $m->content();
But it prints the processing page itself.
Regards, |