in reply to How to make a time-out with LWP::Simple

Getting more out of LWP::Simple by Dog and Pony seems like something you'd like. It explains how to export the UserAgent, to set the timeout.

--
b10m

All code is usually tested, but rarely trusted.
  • Comment on Re: How to make a time-out with LWP::Simple

Replies are listed 'Best First'.
Re: Re: How to make a time-out with LWP::Simple
by coldfingertips (Pilgrim) on Mar 25, 2004 at 18:08 UTC
    Okay, I went to that and I now know how to set a timeout. The question is now, how do I check for it? Rather than just timing out and moving on, I need to print a message stating it skipped it to browser.
    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!"; }