Created
November 7, 2012 18:43
-
-
Save douglasdrumond/4033530 to your computer and use it in GitHub Desktop.
Download machine learning videos from Coursera
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
import re, urllib | |
htmlSource = urllib.urlopen("https://class.coursera.org/ml/lecture/preview/1").read(200000) | |
linksList = re.findall('data-lecture-view-link="(.*?)"', htmlSource) | |
allVideos = [] | |
for link in linksList: | |
print 'Open', link | |
htmlWithVideo = urllib.urlopen(link).read(200000) | |
videosList = re.findall('<source.*type="video/mp4".*? src="(.*?)"',htmlWithVideo) | |
print 'Videos:', videosList | |
allVideos.extend(videosList) | |
for video in allVideos: | |
print 'Download', video | |
fileName = video[video.rfind('/')+1:] | |
urllib.urlretrieve(video, fileName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment