in reply to Trying to download video from URL links

use LWP::Simple; $url = get("https://class.coursera.org/automata-002/lecture/index"); $link = ''; foreach (split /\n/, $url){ if(/download\.mp4/){ $_ =~m/href="(.+)"/; $link = $1; } if(/(Video \(MP4\) for )(.+)<\/div>/){ print "downloading $2\n" if $1; $file = get($link); open FILE,'>'.$2.'.mp4' or die $!; print FILE $file; close FILE; } }
update
though it downloads the files
they can't be opened afterwards
my bad, sorry
P.S. Why are you against wget?

Replies are listed 'Best First'.
Re^2: Trying to download video from URL links
by soonix (Chancellor) on Dec 22, 2013 at 12:04 UTC
    though it downloads the files
    they can't be opened afterwards
    Do you happen to work on a Windows machine? Then binmode is your friend.
Re^2: Trying to download video from URL links
by soulrain (Initiate) on Dec 22, 2013 at 05:17 UTC
    Not against wget just want to see how to do it with WWW:Mechanize or perhaps another module... I was reading the documentation wrong which is easy for me to do as I am just learning Perl...