use HTML::TokeParser::Simple;
$uatopasson = $ENV{"HTTP_USER_AGENT"};
$referertopasson = $ENV{"HTTP_REFERER"};
$ua = LWP::UserAgent->new;
$ua->agent($uatopasson);
$req = HTTP::Request->new (GET => "$file");
$req->header('referer' => $referertopasson);
$res = $ua->request($req);
$webpage = $res->content;
print "Content-type: text/html\n\n";
$parser = HTML::TokeParser::Simple->new(\$webpage);
$html = '';
$parser->get_tag('body'); # skip to first body tag
while (my $token = $parser->get_token) {
last if $token->is_end_tag('body');
$html .= $token->as_is;
}
print $html;
I would also like to point out that I've very reluctantly left off "use strict" and warnings. Check the link to my CGI course (below) for more information.
|