in reply to Re: Robust Handling of Broken Links in Mechanize?
in thread Robust Handling of Broken Links in Mechanize?
This is great stuff ... it looks like this fixes the problem:
Thanks for your help! It made my day.
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 );