Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Downloading and saving images.
by BrowserUk (Patriarch) on Sep 07, 2006 at 04:58 UTC | |
by Anonymous Monk on Sep 07, 2006 at 05:01 UTC | |
by jonadab (Parson) on Sep 07, 2006 at 12:05 UTC | |
by BrowserUk (Patriarch) on Sep 07, 2006 at 12:17 UTC | |
|
Re: Downloading and saving images.
by jZed (Prior) on Sep 07, 2006 at 04:56 UTC | |
|
Re: Downloading and saving images.
by b10m (Vicar) on Sep 07, 2006 at 07:19 UTC | |
|
Re: Downloading and saving images.
by zentara (Cardinal) on Sep 07, 2006 at 13:30 UTC |