use strict;
use LWP::Simple;
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
$ua->max_redirect(0);
my $response = $ua->get('http://www.msn.co.uk');
if ($response->is_success)
{
while (my ($x,$y) = each (%$response))
{
print "$x - $y\n";
}
}
else
{
die $response->status_line;
}
####
$VAR1 = bless( {
'_protocol' => 'HTTP/1.1',
'_content' => '',
'_rc' => '301',
'_headers' => bless( {
'x-powered-by' => 'ASP.NET',
'client-response-num' => 1,
'cache-control' => 'no-cache',
'set-cookie' => 'MC1=V=3&GUID=e03d ....',
'location' => 'http://uk.msn.com/',
'date' => 'Mon, 27 Sep 2010 15:31:10 GMT',
'client-peer' => '213.199.164.24:80',
'content-length' => '0',
'x-aspnet-version' => '2.0.50727',
'p3p' => 'CP="BUS CUR CONo FIN IVDo ONL ..."',
'client-warning' => 'Redirect loop detected (max_redirect = 0)',
'client-date' => 'Mon, 27 Sep 2010 15:31:54 GMT',
'pragma' => 'no-cache',
'server' => 'Microsoft-IIS/6.0',
's:' => '04'
}, 'HTTP::Headers' ),
'_msg' => 'Moved Permanently',
'_request' => bless( {
'_content' => '',
'_uri' => bless( do{\(my $o = 'http://www.msn.co.uk')}, 'URI::http' ),
'_headers' => bless( {
'user-agent' => 'libwww-perl/5.803'
}, 'HTTP::Headers' ),
'_method' => 'GET'
}, 'HTTP::Request' )
}, 'HTTP::Response' );
####
_protocol - HTTP/1.1
_content - bunch of content
_rc - 200
_headers - HTTP::Headers=HASH(0x1cde8fc)
_previous - HTTP::Response=HASH(0x1cc618c)
_msg - OK
_request - HTTP::Request=HASH(0x1c7e310)