I am tring to download images from a website and save them on my hard drive. The method I am using only results in corrupted images that will not open. Im new to Perl and I cant seem to find any online resources to help me with my problem. This is what I have so far:
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $response = $ua->get('url_to_some_picture.jpg');
open(outfile, '>file_path_name');
if ($response->is_success) {
print outfile $response->content;
}
else {
die $response->status_line;
}
Code tags added by GrandFather