Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

stopping www::mechanize from exiting after a timeout

by incognito129 (Acolyte)
on Aug 14, 2009 at 05:55 UTC ( #788526=perlquestion: print w/replies, xml ) Need Help??

incognito129 has asked for the wisdom of the Perl Monks concerning the following question:

I have a script using www::mechanize to fetch a few pages. However sometimes the sites are down and after mechanize timeouts on the site it exits completely instead of moving on. How do I get mechanize to not quit and continue on?
  • Comment on stopping www::mechanize from exiting after a timeout

Replies are listed 'Best First'.
Re: stopping www::mechanize from exiting after a timeout
by Corion (Pope) on Aug 14, 2009 at 06:41 UTC
Re: stopping www::mechanize from exiting after a timeout
by Anonymous Monk on Aug 14, 2009 at 07:29 UTC
    You can catch die's with eval {}, example
    #!/usr/bin/perl -- use strict; use warnings; use WWW::Mechanize; my $ua = WWW::Mechanize->new( autocheck => 1 ); for ( 1, 6 ){ eval { $ua->get('die://die'); 1 } or print "$@\n"; } __END__ Error GETing die://die: Protocol scheme 'die' is not supported at - li +ne 9 Error GETing die://die: Protocol scheme 'die' is not supported at - li +ne 9
    Or turn autocheck off, and do your own checking.
Re: stopping www::mechanize from exiting after a timeout
by desemondo (Hermit) on Aug 14, 2009 at 06:48 UTC
    Based on the very limited info you've provided - its a bit hard to provide much help.

    Maybe consider:
    1. Paste your code thats 'exiting'
    2. Provide the specific output thats being generated, or specificy at what point your code is exiting.

    At a guess, it might be due to an exception thats being thrown in one of the modules that www::mechanize uses. If so, you can neutralise it via a block eval.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://788526]
Approved by ELISHEVA
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2021-11-27 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?