Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

http client

by Anonymous Monk
on Mar 02, 2002 at 00:18 UTC ( [id://148735]=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://148735]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-18 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found