#!/usr/bin/perl -w
use strict;
use warnings;
use WWW::Mechanize;
my $total_args = $#ARGV + 1;
if ($total_args != 3) {
print "usage: getLinks url regEx suffix(file type)\n";
exit;
}
my $mech = WWW::Mechanize->new();
my $url = $ARGV[0];
my $regEx = $ARGV[1];
my $fileType = ".".$ARGV[2];
$mech->get($url);
my @links = $mech->find_all_links( url_regex => qr#$regEx# );
for my $link(@links) {
printf("Following: %s\n at address: %s\n", $link->text, $link->url
+);
printf("Saving file as %s\n", $link->text.$fileType."\n");
$mech->get($link->url, ':content_file' => $link->text.$fileType);
}
I would like to add a progress bar similar to what wget uses so could you explain a bit more about:
$lwpmechua->show_progress( 1 )?
Thanks as always! |