http://qs321.pair.com?node_id=427129

use strict; use warnings; use WWW::Mechanize; use MIME::Base64; my $PW = 'PWPWPW'; my $auth = MIME::Base64::encode("" . ':' . $PW); my $mech = WWW::Mechanize->new(); #$mech->default_headers->authorization_basic("", $pw); $mech->add_header( 'Authorization' => 'Basic ' . $auth ); $mech->get('http://192.168.1.254/left1.htm'); print $mech->content; __END__ my $mech = WWW::Mechanize->new(); my @args = (Authorization => "Basic " . MIME::Base64::encode("" . ':' . $PW)); $mech->credentials('192.168.1.254:80', 'ABCDEF', "", $PW); $mech->get('http://192.168.1.254/', @args); print $mech->content; warn MIME::Base64::encode("" . ':' . $PW) . "-"; __END__ my $mech = WWW::Mechanize->new(); #$mech->default_headers->authorization_basic("", $pw); #$mech->add_header( 'Authorization' => 'Basic OmVsbHkwMA==' ); #$mech->get('http://192.168.1.254/left1.htm'); $mech->get('http://www.google.com'); print $mech->content;