Skip to content

Instantly share code, notes, and snippets.

@douglasdrumond
Created November 7, 2012 18:43
Show Gist options
  • Save douglasdrumond/4033530 to your computer and use it in GitHub Desktop.
Save douglasdrumond/4033530 to your computer and use it in GitHub Desktop.
Download machine learning videos from Coursera
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