Here is a small script on how to login to a .htaccess protected page. Suppose that URL we want to login to is:

http(:)//www(.)example(.)com/

and here are credentials required to login:

username: www
password: mechanize

The perl script to fetch the content of this page will look like this:

#!/usr/bin/perl

use WWW::Mechanize;
my $mech = WWW::Mechanize->new( autocheck => 1 );

$url = 'http://www.example.com/';
$mech->credentials( 'www' => 'mechanize' );
    $mech->get( $url );
    print $mech->content();


Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top