http://www.perlmonks.org?node_id=974529


in reply to LWP-Download 401 Authorization Required

You may also be running afoul of the fact that LWP doesn't handle cookies itself. It's common that you access a login URL, supplying the username and password via POST; the application returns a cookie, which then must be passed back again when GETting a resource.

HTTP::Cookies should help. From the synopsis:

use HTTP::Cookies; $cookie_jar = HTTP::Cookies->new( file => "$ENV{'HOME'}/lwp_cookies.dat", autosave => 1, ); use LWP; my $browser = LWP::UserAgent->new; $browser->cookie_jar($cookie_jar);
At this point, the getting and saving of cookies should happen pretty much automatically.