It is very simple to get a protected page using LWP::UserAgent. A little example:
use LWP::UserAgent; use HTTP::Request; use HTTP::Cookies; # setup your browser $ua = LWP::UserAgent->new(keep_alive => 1, timeout => 300); # what kind of browser you are $ua->agent("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/200 +21207 Phoenix/0.5"); # a place to store cookies, if needed $ua->cookie_jar( HTTP::Cookies->new(file => "perlcookies.dat", autosav +e => 1) ); # now build a request $request = HTTP::Request->new( GET => $url ); # set credentials $request->authorization_basic($username, $password); # run browser $response = $ua->request($request); # and check response if ($response->is_success) { print $response->content, "\n"; } else { die "failed: ", $response->message, "\n"; }
Happy downloading :) Valerio
In reply to Re: Grabbing Webpages with Usernames and Passwords
by valdez
in thread Grabbing Webpages with Usernames and Passwords
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |