Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Trying to download video from URL links

by Anonymous Monk
on Dec 22, 2013 at 15:38 UTC ( [id://1068099]=note: print w/replies, xml ) Need Help??


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

... :content_file ...

A few hours ago Re^2: Trying to download video from URL links the op figured it out :)

... progress bar ... additional code ...

 $lwpmechua->show_progress( 1 );

hi :)

Replies are listed 'Best First'.
Re^3: Trying to download video from URL links
by soulrain (Initiate) on Dec 22, 2013 at 21:05 UTC

    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!

      $lwpmechua is $mech in your code
Re^3: Trying to download video from URL links
by aitap (Curate) on Dec 27, 2013 at 17:16 UTC

     $lwpmechua->show_progress( 1 );
    Wow. There is even WWW::Mechanize::Plugin::Retry which probably can be hacked to automatically continue partial downloads, so Mechanize eventually could replace wget.

    While I have to admit that I didn't remember about show_progress, the progress bar of wget shows the percentage and ETA and the -c option automagically continues a broken download which doesn't look like a simple task in Mechanize.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1068099]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-18 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found