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.
|