I am using the following code to try to get the src attribute from all the img tags from a webcomic
#!"C:\xampp\perl\bin\perl.exe"
use strict;
use warnings;
use LWP::UserAgent;
use CGI qw(:standard :cgi-lib -debug fatalsToBrowser warningsToBrowser
+);
use HTML::TokeParser;
my $cgi = new CGI;
print $cgi->header();
print start_html(-title =>'Save QC');
print "Starting...",br;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
$ua->agent('Mozilla/5.0 Windows Gecko/30.0 Firefox/30.0');
my $response = $ua->get('http://questionablecontent.net/');
if ($response->is_success) {
# print $response->decoded_content; # or whatever
print br,br,"Success!";
my $tp = HTML::TokeParser->new(\$response) || die "Can't open: $!"
+;
while (my $token = $tp->get_tag('img')) {
my $src = $token->[1]{'src'};
print "src =",$src,br
}
} else {
print $response->decoded_content; # or whatever
print br,br,"Failure!";
die $response->status_line;
}
print end_html;
I get the whole page when I "print response->decoded_content;", but I don't get anything from the get-tag line. What am I doing wrong?
I am running this on a windows machine.