I'd like to be able to get a copy of an image that I've seen on a webpage into a image editing/display program. The HTML fragment associated with the image looks like:
<img src='images/theimage.png' border='0'/>
my Perl code to download and save the image looks like:
my $browser = LWP::UserAgent->new();
my $response;
$browser->env_proxy();
$browser->cookie_jar($cookie_jar);
my $Image = '
$response = $browser->get($Image);
my $FileName = 'C:\Perl\Image.png';
open "CONTENT", ">", $FileName;
print CONTENT $response->content();
close CONTENT;
This seems to be working ok in the sense that the code produces an output file that looks like it has a bunch of binary stuff in it that starts with a character followed by 'PNG'. But I am unable to open the file with my picture viewer. Is there some sort of header that needs to be removed so that the image file is valid?
A second question: Another part of the HTML that I am looking at looks like the following:
<img id="image2" src="../image2.asp" />
The extension on this picture doesn't look familiar to me (it's not .gif, .png, etc.). How can I tell how to interpret the response to getting this file?
<img src='images/theimage.png' border='0'/>
my Perl code to download and save the image looks like:
my $browser = LWP::UserAgent->new();
my $response;
$browser->env_proxy();
$browser->cookie_jar($cookie_jar);
my $Image = '
$response = $browser->get($Image);
my $FileName = 'C:\Perl\Image.png';
open "CONTENT", ">", $FileName;
print CONTENT $response->content();
close CONTENT;
This seems to be working ok in the sense that the code produces an output file that looks like it has a bunch of binary stuff in it that starts with a character followed by 'PNG'. But I am unable to open the file with my picture viewer. Is there some sort of header that needs to be removed so that the image file is valid?
A second question: Another part of the HTML that I am looking at looks like the following:
<img id="image2" src="../image2.asp" />
The extension on this picture doesn't look familiar to me (it's not .gif, .png, etc.). How can I tell how to interpret the response to getting this file?