davido has asked for the wisdom of the Perl Monks concerning the following question:
I've read the POD for WWW::Mechanize, and done a bit of searching and reading here at the Monastery, but haven't been able to come up with a solution to what I believe is probably a pretty simple question.
I want to log in to an htaccess-protected site via WWW::Mechanize. As an example of such a site I have been trying to log in to my router's configuration page. Here is a simple example script, which isn't successful:
use strict; use warnings; use WWW::Mechanize; my $agent = WWW::Mechanize->new( autocheck => 1 ); $agent->credentials( 'www.routerlogin.com', 'WGR614v4', 'user', 'password' ); $agent->get( 'http://www.routerlogin.com/s_status.htm' ); print $agent->content();
The output is:
Error GETing http://www.routerlogin.com/s_status.htm: Unauthorized at mytest.pl line 14
Note: The URL I'm using is automatically trapped by my router and associated with the router's configuration screen. I could also have just used the router's local IP address of 192.168......etc.
I know this can't be that difficult. After all, WWW::Mechanize is a proper subclass of LWP::UserAgent, but I just can't seem to quite get it right. Any suggestions or pointers to a good discussion on the topic would be greatly appreciated.
Dave