hello,

what would be the best module to download a file from an https://url ? I am 
trying to download some files over secured website and am willing to try the 
most correct (no overkill) module for the job.


task: to download files from secured websites, using perl script:  
https://myurl/file.doc

https://myurl/ needs username password and sets a cookie too, which expires in 
24 hours.


so far i tried: which is failing me on how to submit username and password and 
also accept the cookie. thx in advance.



#!/usr/bin/perl
use strict;
use warnings;
use LWP;
use Data::Dumper;

my $ua = LWP::UserAgent->new;
my $agent = "my-lwp agent";
$ua->agent($agent);
$ENV{HTTPS_PROXY} = 'http://myproxy:8080';

my $req = HTTP::Request->new(GET => 'https://myurl/file.doc');
$req->content_type('text/html');
$req->protocol('HTTP/1.0');  #try use an oder version

my $response = $ua->request($req);     # add , 'teste_https.html' to save with 
a name...
 if ($response->is_success) {
     print "1 success\n";   #$response->decoded_content;  # or whatever
 }
 else {
    print "1 error\n";
   #  die $response->status_line;
 }


print Dumper $response;


__END__

Reply via email to