I create a perl scripts to get some information from the website. The webpage does not redirect itself and i need to click continue myself to redirect it. Can i do it using perl?
#!/usr/bin/perl -w
use feature ':5.10';
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request::Common qw(POST);
use HTTP::Cookies;
use CACertOrg::CA;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
my $outfile="out.html";
my $URL="http://www.example.com;
my $UA = LWP::UserAgent->new();
$UA->ssl_opts(
SSL_verify_mode => 'SSL_VERIFY_NONE',
verify_hostnames => 0,
SSL_ca_file => CACertOrg::CA::SSL_ca_file()
);
$UA->cookie_jar(HTTP::Cookies->new(file => 'cookie_jar', autosave =>1));
my $req =HTTP::Request::Common::POST("$URL",
Content_type=>'form-data',
Content =>[
'username'=>'user',
'password'=>'pass',
'vhost'=>'standard'
]
);
$req->header('Cookie' =>q(TIN=287000; LastMRH_Session=439960f5; MRHSession=78c9c47291c1fcedae166121439960f5));
my $resp=$UA->request($req);
open(OUTFILE, ">$outfile");
print OUTFILE $resp->decoded_content;
close(OUTFILE);
The out.html
i print out is like this
when i open the html file, it directly redirect to the page i want but not in the code. Anywhere to do it in the code to reach wwww.example.com
.
Added 8/18
I try using this command and it open the www.example.com
in my browser
my $ret = system( 'out.html' );
but what i want is to get the html of www.example.com
instead of open the website.