use WWW::Mechanize::Firefox; use File::Temp qw/ :seekable /; my $url = 'http://192.168.1.1/'; my $formSubmitURL; my $httprealm = 'Default: admin/1234'; my $username = 'admin'; my $password = '1234'; my $res; my $hostname = $url; (my $u = "$url") =~ s!/$!!; my $mech = eval { WWW::Mechanize::Firefox->new( autodie => 0 , launch => '/usr/bin/firefox' || system(qq(which firefox)) , autoclose => 0 , activate => 1 # bring the tab to the foreground , log => [qw[debug]] ) }; my $nsILoginManager = $mech->repl->expr(<<'JS'); Components.classes["@mozilla.org/login-manager;1"] .getService(Components.interfaces.nsILoginManager) JS my $logins = $nsILoginManager->findLogins({}, $url, $formSubmitURL, $httprealm); my $count = $logins->{length}; my $nsILoginInfo; unless($count) { $nsILoginInfo = $mech->repl->expr(<<"JS"); var nsILI = new Components.Constructor( "\@mozilla.org/login-manager/loginInfo;1" , Components.interfaces.nsILoginInfo , "init" ); new nsILI("$hostname", null, "$httprealm", "$username", "$password", "", "") JS # in resource://gre/components/nsLoginManager.js $res = $nsILoginManager->addLogin($nsILoginInfo); } (my $tpl_f = $url) =~ s/.*\/\///g; $tpl_f =~ s/\/.*//g; $tpl_f .= '_XXXXXX'; my $temp_p = File::Temp->newdir(TEMPLATE => $tpl_f, OPEN => 0); my %attr = (':content_file' => $temp_p->dirname . '.html', no_cache => 1); $res = $mech->get($url, %attr); #### $mech->content 'WWW::Mechanize::Firefox' #### Some Technology(.v.)<body></body>