#! /Usr/bin/perl-W # gist: https://gist.github.com/2928006use lwp: simple; my $ url = $ argv [0]; my $ filename = $ argv [1]; my $ content = get ($ URL) or die "couldn't get $ URL ";
# $ Content = ~ S # ^ .*? (<Div .*? </Div>). * $ # m;
If ($ content = ~ M #. * (<Div id = "entext" style = "display: Block"> .*? </Div>). * # SG) {$ text = $1;
# Open the template file open (template, "template.html") or die "couldn't open template.html for writing: $! ";
# Read the Template File $/= "# Replace the listening text $ reads = ~ S/= text_content =/$ text/gix; # Print $ reads;
# Output HTML file open (Out, "> $ FILENAME") or die "couldn't open $ filename for writing: $! "; Print out $ reads;
# Download my $ baseurl = $ URL; $ baseurl = ~ S/(. *) (//. */. html)/$1/g; my $ reslink = $ content; $ reslink = ~ S/. * <a href = "(.*?) "Title =" go to the download Materials page "> download audios </a>. */$1/SG; $ reslink = $ baseurl."/". $ reslink;
Print "/nreslink:", $ reslink, "/N"; my $ respage = get ($ reslink) or die "couldn't get $ reslink ";
My $ mp3link = $ respage; print $ mp3link; # $ mp3link = ~ S #. * <a href = "(.*?) "Target =" _ blank "> </a>. * #$1 # SG; # If ($ mp3link = ~ M/. * <a href = "(.*?) "Target =" _ blank "> </A>. */SG ){
# What should I do if I have not logged on and cannot obtain the download link? If ($ mp3link = ~ M/downloadurl1/SG) {print "match/N";} else {print "do not match/N" ;#< a href = "(.*?) "Target =" _ blank "> </a>
Print "/ndownload:". $ reslink. "/N";} else {print "Mismatch/N ";}