develooper Front page | perl.libwww | Postings from December 2000

problems with LWP::UserAgent

From:
news
Date:
December 6, 2000 15:42
Subject:
problems with LWP::UserAgent
Message ID:
000801c05fd7$c2347900$14429cd4@rbogubaev
Hi,

can you help me to desolve this problem? is where I have mistake in follow script?

exist A.html and B.html pages. how can I get the source of B.html page if page A.html redirect to B.html like in follow HTML example?

<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
   <meta http-equiv="Refresh" content="0; URL=/2000/11/02/">
   <meta name="Author" content="XXXX">
   <title>Some title ... </title>
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">

<center>
        some HTML code ...
</center>

</body>
</html>

I try to get the B.html page source with this script, but only A.html page source is getted ...

#!/usr/bin/perl -w

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use HTTP::Status;
use strict;

my $url = http://localhost/A.html;

my    $ua = LWP::UserAgent -> new();
my    $req = HTTP::Request -> new(GET => $url);
        $ua -> redirect_ok($req);

my    $response = $ua -> request($req);

if ($response -> is_success){
        my    $content = $response -> content();

        print "content-type: text/html\n\n";
       print "$content";
}



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About