in reply to Re^2: Trying to download video from URL links
in thread Trying to download video from URL links

So I added the ability to pass in command line arguments: para(1): url, para(2): regex in link you are looking for, para(3): is the fileExtension you want appended onto link text

#!/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!

Replies are listed 'Best First'.
Re^4: Trying to download video from URL links
by Anonymous Monk on Dec 24, 2013 at 06:39 UTC
    $lwpmechua is $mech in your code