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!


In reply to Re^3: Trying to download video from URL links by soulrain
in thread Trying to download video from URL links by soulrain

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.