Hello all. I am trying to go to a webpage and save the html source. My code is below:
my $cookie_jar = HTTP::Cookies->new(file => "lwp_cookies.dat",autosave => 1);
my $agent = new LWP::UserAgent();
$agent->cookie_jar($cookie_jar);
$agent->credentials($URL,'','username','password');
my $request = new HTTP::Request( 'GET' => $URL );
$cookie_jar->add_cookie_header($request);
$request = new HTTP::Request( 'GET' => $URL );
my $response = $agent->request( $request );
my $html = $response->content();
So, the contents of source html of $URL should be stored at $html, right? The problem I'm running into is that $URL is a webpage on a secure site. So, when I try to go directly there the PERL script gets redirected to an authentication page. However the script isn't going to the redirected location and the only thing that gets stored at $html is a webpage with the word "Redirect" in the body. I would be greatful to anyone who can shed some light on this for me. I have alot of experience with PERL but next to none with HTML and dealing with HTTP requests. Thanks in advance.
my $cookie_jar = HTTP::Cookies->new(file => "lwp_cookies.dat",autosave => 1);
my $agent = new LWP::UserAgent();
$agent->cookie_jar($cookie_jar);
$agent->credentials($URL,'','username','password');
my $request = new HTTP::Request( 'GET' => $URL );
$cookie_jar->add_cookie_header($request);
$request = new HTTP::Request( 'GET' => $URL );
my $response = $agent->request( $request );
my $html = $response->content();
So, the contents of source html of $URL should be stored at $html, right? The problem I'm running into is that $URL is a webpage on a secure site. So, when I try to go directly there the PERL script gets redirected to an authentication page. However the script isn't going to the redirected location and the only thing that gets stored at $html is a webpage with the word "Redirect" in the body. I would be greatful to anyone who can shed some light on this for me. I have alot of experience with PERL but next to none with HTML and dealing with HTTP requests. Thanks in advance.