Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Robust Handling of Broken Links in Mechanize?

by Wolfgang (Novice)
on Nov 20, 2009 at 11:25 UTC ( [id://808395]=note: print w/replies, xml ) Need Help??


in reply to Robust Handling of Broken Links in Mechanize?

The WWW::Mechanize documentation at CPAN explains the option 'onerror'. Try using it, it may help ;-) Since yo did not set any options, Mechanize falls back to the standards it's author found most helpful. Wolfgang
  • Comment on Re: Robust Handling of Broken Links in Mechanize?

Replies are listed 'Best First'.
Re^2: Robust Handling of Broken Links in Mechanize?
by pat_mc (Pilgrim) on Nov 20, 2009 at 12:58 UTC
    Wolfgang -

    This is great stuff ... it looks like this fixes the problem:
    sub download() { my $doc = shift @_; my $mech = WWW::Mechanize -> new( onerror => undef ); return unless defined( $mech -> get( $doc ) ); my $link = $mech -> find_link( url_regex => qr/\.pdf/ ); return unless defined( $link ); $link = $link -> url_abs; return unless ( $mech -> get ( $link ) ); # This is the GET oper +ation which fails. my $name = $1 if $link =~/.+\/(.+\.pdf)/; $mech -> save_content( $name ); }
    Thanks for your help! It made my day.

    Cheers -

    Pat

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-19 20:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found