Nov 28, 2007, 4:52 AM
Post #1 of 4
Using Credentials on LWP
I want to download a pdf file from password protected website. Using browser when i click the pdf link it shows a window, which asks 'username' and 'password'. I want to automate the process using LWP in perl. I have used both 'authorization_basic' and 'credentials', but doesn't work.
my $url = 'http://www.server.com/V73-2.pdf';
my $file = 'C:/one.pdf';
my $ua = LWP::UserAgent->new(keep_alive=>1);
$ua->credentials('www.server.com:80', '', 'MyDomain\MyUserName', 'MyPassword');
my $request = GET $url;
my $response = $ua->request($request, $file);
and also used authorization_basic
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new(GET => $url);
my $request->authorization_basic($user_id, $user_pass);
There is no realm appears for that.
When I use the credentials i get the error output as:
Error: Negotiate, NTLM
401 Unauthorized at http://www.server.com/V73-2.pdf
Aborting at credential.pl line 19.
When i use authorization_basic i get the error as:
You are not authorized to view this page