in reply to Re: How to make a time-out with LWP::Simple
in thread How to make a time-out with LWP::Simple
use CGI qw/:standard/; use LWP::Simple qw(!head $ua); use LWP::UserAgent; use HTML::LinkExtor; use URI::URL; my $ua = LWP::UserAgent->new; $ua->timeout(10); my $p = HTML::LinkExtor->new; my $res = $ua->request(HTTP::Request->new(GET => $url), sub {$p->parse($_[0])}); #### INSERT TIMEOUT CHECK HERE if (timeout) { print "This url timed out"; } if ($res->status_line =~ /NOT FOUND/i) { print "NOT FOUND!"; }
|
|---|