Subject: | WWW-Mechanize and redirects http/https |
Hello,
This is pretty minor and a fairly uniqe situation but strange to me anyhow.
It works fine with other sites but, I have a redirection situation that I have to check from http to https. Below are two sample scripts. The first using WWW::Mechanize returns status 500, The second useing LWP::UserAgent
Works fine.
Cheers
Andrew Smith
Show quoted text
_________________________________________________________________________
#!/usr/bin/perl -w
use strict;
use WWW::Mechanize;
my $url = 'http:/web08.hj.scd.yahoo.com' ;
my $agent = WWW::Mechanize->new( agent => "Mozilla/*." );
&geturl;
&printStuff;
sub geturl {
$agent->get($url) or die "could not open $url";
print "we made it here $url \n" ;
}
sub printStuff {
print "content $agent->{content}\n\n";
print "$agent->{status}\n\n";
}
__________________________________________________________________________
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
my $link = 'https://web08.hj.scd.yahoo.com';
&getPage;
sub getPage {
my $ua = LWP::UserAgent->new;
# $ua->agent("$0/0.1 " . $ua->agent);
$ua->agent("Mozilla/8.0"); # pretend we are very capable browser
my $req = HTTP::Request->new(GET => "$link");
$req->header('Accept' => 'text/html');
# send request
my $res = $ua->request($req);
# check the outcome
if ($res->is_success) {
print $res->code ;
# print $res->content;
} else {
print "Error: " . $res->status_line . "\n";
}
}
__________________________________________________________________________