use HTTP::Request;
use HTTP::Response;
use LWP::UserAgent;
use IO::File;
my $ua=LWP::UserAgent->new();
$filename=shift or die "usage: $0 request_file\n";
open(in_file,"$filename") or die "Can't open $filename.\n";
$name="~~result.html";
open(FH,">$name") or die "Unable to create temp file:$!";
print FH "<HTML><TITLE>Perl's Good</TITLE><BODY>\n";
while(<in_file>){ chomp(); if($_) {$urls{$_}=0;} }
foreach $key (keys %urls){ &process_url($key);}
print FH "</BODY></HTML>";
if($^O=~/win/ig){`explorer $name`;}else{`firefox $name`;};
sub process_url
{
my $param=shift or die "need parameter to continue\n";
if($param!~/^http:/i){$param="http://".$param;}
my $req=HTTP::Request->new(GET=>$param);
my $response=$ua->request($req);
if($response->is_error()){print $param,"---> ", $response->status_line,"\n";}
else
{
$content=$response->content();
print FH "<HR/><CENTER><STRONG><A href=$param>$param</A></STRONG></CENTER><BR/>\n";
while($content=~/src=\s*"?(\S+\.jpe?g)"?/cig){print FH "<IMG src=$1 />\n";$urls{$param}++; }
print FH "<BR/><CENTER>----------$urls{$param} picture(s)-----</CENTER><BR/>\n";
print $param," --->",$urls{$param}," pictures\n";
}
}
July 2006 August 2006 September 2006 October 2006 August 2007 November 2007 March 2008 April 2008 May 2008 October 2008
Subscribe to Posts [Atom]