Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

stopping www::mechanize from exiting after a timeout

by incognito129 (Acolyte)
on Aug 14, 2009 at 05:55 UTC ( [id://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 (Patriarch) 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?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2025-03-21 07:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (63 votes). Check out past polls.