Skip to content

Instantly share code, notes, and snippets.

@paulcarey
Created January 12, 2013 14:04
Show Gist options
  • Save paulcarey/4518200 to your computer and use it in GitHub Desktop.
Save paulcarey/4518200 to your computer and use it in GitHub Desktop.
Script to download Coursera lecture notes
require 'restclient'
# Create the list from the course page by running the following JavaScript
# snippet, and copying and paste the results in here. I _think_ the Content-Type
# of the pdfs prevents them from being downloaded directly in JavaScript.
# $('.course-lectures-list ul:eq(2) a[href$="pdf"]').map(function () { return $(this).attr('href') })
urls = ["https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Flecture3.pdf",
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Ffunctions.pdf",
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Fscopingrules.pdf",
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Foptimization.pdf",
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Flapply.pdf",
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Fapply.pdf",
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Ftapply.pdf",
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Fmapply.pdf",
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Fdebugging1.pdf",
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Fdebugging2.pdf",
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Fdebugging3.pdf"]
urls.each do |url|
fn = url.split('/')[-1].sub('%2F', '_')
puts "Downloading #{url}"
RestClient.get(url) do |resp|
File.open(fn, "w") { |f| f.write(resp) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment