pat_mc has asked for the wisdom of the Perl Monks concerning the following question:
Unfortunately, the script still aborts as soon as the broken link is encountered.sub download() { my $doc = shift @_; my $mech = WWW::Mechanize -> new(); 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 ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Robust Handling of Broken Links in Mechanize?
by Wolfgang (Novice) on Nov 20, 2009 at 11:25 UTC | |
by pat_mc (Pilgrim) on Nov 20, 2009 at 12:58 UTC | |
|
Re: Robust Handling of Broken Links in Mechanize?
by vishi83 (Pilgrim) on Nov 20, 2009 at 12:09 UTC |