Created
May 24, 2012 16:10
-
-
Save markuskreitzer/2782462 to your computer and use it in GitHub Desktop.
Dr. Reeves Video Lecture Series for Random Signals and Systems Extraction Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use WWW::Mechanize; | |
use LWP::Simple; | |
use File::Basename; | |
my $url = "http://www.eng.auburn.edu/~reevesj/Classes/ELEC3800/restricted/modules.html"; | |
my $mech = WWW::Mechanize->new(); | |
$mech->agent_alias('Windows IE 6'); | |
$mech->get( $url ); | |
my @links = $mech->find_all_links( url_regex => qr/\.html$/ ); | |
foreach(@links){ | |
my $link = ($_->url_abs()); | |
# The following code was for extracting the swf file and then the mp4 file. | |
# I noticed that the mp4 file had the same filename as the html file though, | |
# so it was not necessary to do this. | |
# print "Getting swf filename from page."; | |
# my @page = get($link); | |
# foreach(@page){ | |
# if( m/\<param\sname\=\"movie\"\svalue\=\"(.+\.swf)\"/g){ | |
# #print "filename: $1\n"; | |
# my $swf = $1; | |
# #push(@swf,$1); | |
# my $basename = basename($link); | |
# $link =~ s/$basename/$swf/g; | |
# } | |
# } | |
$link =~ s/html/mp4/g; # Change html extension to mp4. | |
print "Link: $link\n"; # Print URL. | |
my $filename = basename($link); # Extract filename only. | |
print "Storing to file: $filename\n"; # Message | |
my $ret = getstore( $link , $filename); # Get and store the filename at URL. | |
print "$ret\n"; # Print return code from HTML response. SHould be 200 for success. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment