[pm-h] Strip Links from FTP

Mike Flannigan mikeflan at att.net
Fri Apr 3 05:58:00 PDT 2009


Andy Lester wrote:
> If you just want to get links from a page of HTML, use WWW::Mechanize 
> and it will do all the extraction for you.
>

Thanks for the advice.  It still doesn't work
for me (Can't use an undefined value as an
ARRAY reference at Mechanize.pl line 834),
but I'm still playing with it.

I can dereference the thing, but I can't get
it to work.


use strict;
use warnings;
use WWW::Mechanize;

my $m = WWW::Mechanize->new;

$m->get("ftp://mcmcftp.er.usgs.gov/Katrina/508dpi/");


my @links = $m->find_all_links(
        tag => "a", url_regex => qr/\.(tif)$/i );

open OUT, ">", 'links.txt' or die "$0: open links.txt: $!";

print @links;
print OUT @links;

close OUT;


__END__






More information about the Houston mailing list