Hello!  I am trying to log into a web page that confounds the simply recipie
given in lwptoot.

My code is as follows:

----------------------------------
use strict;
use LWP::UserAgent;
use HTML::Parse;
use HTML::FormatText;

my $user = "";  #username taken out
my $pwd = "";  #password taken out
my $ua = new LWP::UserAgent;

# Create a request
my $url = qq(http://www5.ncdc.noaa.gov/ulcd/);
my $req = new HTTP::Request GET => $url;

$req->proxy_authorization_basic($user, $pwd);
my $res = $ua->request($req);
print $res->content;
------------------------------------

The login always fails.  I'm certain of the user/password because I can log
in using Explorer.  Am I missing something?

When I dump the $req var I get

0  HTTP::Response=HASH(0x5c837c)
   '_content' => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>401 Authorization Required</TITLE>
</HEAD><BODY>
<H1>Authorization Required</H1>
This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn\'t understand how to supply
the credentials required.<P>
</BODY></HTML>
'
   '_headers' => HTTP::Headers=HASH(0x5c834c)
      'client-date' => 'Tue, 23 Apr 2002 17:47:53 GMT'
      'client-peer' => '205.167.24.197:80'
      'connection' => 'close'
      'content-type' => 'text/html; charset=iso-8859-1'
      'date' => 'Tue, 23 Apr 2002 17:47:52 GMT'
      'server' => 'Apache/1.3.12 (Unix) ApacheJServ/1.0b3'
      'title' => '401 Authorization Required'
      'www-authenticate' => 'Basic
realm="UneditedLCD_USERNAME/PASSWORDisUPPERCASE"'
   '_msg' => 'Authorization Required'
   '_protocol' => 'HTTP/1.1'
   '_rc' => 401
   '_request' => HTTP::Request=HASH(0xeee00)
      '_content' => ''
      '_headers' => HTTP::Headers=HASH(0xeee6c)
         'proxy-authorization' => 'Basic U05PVzpTTk9XMQ=='
         'user-agent' => 'libwww-perl/5.47'
      '_method' => 'GET'
      '_uri' => URI::URL=ARRAY(0xeee9c)
         0  URI::http=SCALAR(0x24bf74)
            -> 'http://www5.ncdc.noaa.gov/ulcd/'
         1  undef





Thanks in advance

Reply via email to