Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: How to authenticate / login htaccess with WWW::Mechanize

by davido (Cardinal)
on Dec 21, 2004 at 22:23 UTC ( [id://416642]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Automatically fill out web forms from the command line
in thread Automatically fill out web forms from the command line

I posted about this a few weeks ago and bart helped me to find the answer. Here's an example snippet of how to authenticate an htaccess system with WWW::Mechanize:

use strict; use warnings; use WWW::Mechanize; my $agent = WWW::Mechanize->new( autocheck => 1 ); $agent->credentials( 'www.somesite.com:80', 'somerealm', 'user', 'password' ); $agent->get( 'http://www.somesite.com/index.html' ); print $agent->content();

It's important to use the port number in the credentials URL. The realm is also important to get right. You can usually see it as the title of the dialog box that pops up in your browser when you visit an htaccess-restricted site.


Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-25 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found