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

problems with LWP::UserAgent

December 6, 2000 15:42
problems with LWP::UserAgent
Message ID:

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">
   <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>
<body text="#000000" bgcolor="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">

        some HTML code ...


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";
} Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About