TheFlyingCorpse has asked for the wisdom of the Perl Monks concerning the following question:
1:
my $username = "someuser"; my $password = "password"; my $url = 'http://sub.example.com:49282/navigation/nav_home.shtml'; use LWP::UserAgent; $ua = LWP::UserAgent->new; $req = HTTP::Request->new(GET => $url); $req->authorization_basic($username,$password); print $ua->request($req)->as_string;
2:
## LWP! use LWP; use strict; my $username = 'username'; my $password = 'password'; my $url = 'http://server:49282/subpage/nav_home.shtml'; my $browser = LWP::UserAgent->new('Mozilla'); $browser->credentials("server:49282","Digest realm",$username=>$passwo +rd); my $response=$browser->get($url); print $response->content();
3:
The site I try to log in to should not have any fancy mechanics to avoid being logged into via Scripts. ANy ideas or examples of how I can log in? From what I've read up on Basic authentication, it can't authenticate until it has got the WWW-Authorization header from the server, which is what I've loaded up the correct credentials for. I've also tried to load the page, do the "reply" in terms of credentials, without success.## WWW::Mechanize #!/usr/bin/perl use WWW::Mechanize; my $username = 'username'; my $password = 'password'; my $url = 'http://server:49282/subpage/nav_home.shtml'; # Create a new instance of WWW::Mechanize my $mechanize = WWW::Mechanize->new(autocheck => 1); # Supply the necessary credentials $mechanize->credentials("server:49282","Digest realm", $username=>$pas +sword); $mechanize->get($url); # Retrieve the desired page print $mechanize->content();
|
|---|