Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a perl script that needs to access a web page, and present authentication credentials back to the web server. It is essentially a http client, then reload the page properly, and log the results, everything is fine except for the authentication, It someone could point me in the right direction it would be appreciated

Replies are listed 'Best First'.
•Re: http client
by merlyn (Sage) on Mar 02, 2002 at 00:24 UTC
    perldoc lwpcook says:
    ACCESS TO PROTECTED DOCUMENTS Documents protected by basic authorization can easily be accessed like this: use LWP::UserAgent; $ua = LWP::UserAgent->new; $req = HTTP::Request->new(GET => 'http://www.linpro.no/secret +/'); $req->authorization_basic('aas', 'mypassword'); print $ua->request($req)->as_string; The other alternative is to provide a subclass of LWP::UserAgent that overrides the get_basic_credentials() method. Study the lwp-request program for an example of this.

    -- Randal L. Schwartz, Perl hacker

      It may not be relevant..... but you scare me ;)
Re: http client
by steves (Curate) on Mar 02, 2002 at 09:41 UTC

    I've also dealt with some sites where authtentication is just a form. For example, this was enough to get me into one:

    use HTTP::Request::Common; my ($user, $password); # Set to whatever ... my $request = POST("http://www.whatever", Content => [ UserID => $user, Password => $password, ]); # Feed the request to LWP::UserAgent, etc.