Skip to content

Instantly share code, notes, and snippets.

@bachue
Created February 6, 2017 07:01
Show Gist options
  • Save bachue/626f521c38d321f43b951ffb00ac0261 to your computer and use it in GitHub Desktop.
Save bachue/626f521c38d321f43b951ffb00ac0261 to your computer and use it in GitHub Desktop.
下载数值分析的视频
require 'rest_client'
require 'nokogiri'
HOST = 'http://moocs.nccu.edu.tw'.freeze
html = Nokogiri::HTML(RestClient.get(HOST + '/course/14/section/lecture').body)
html.css('li.lecture>.main>.title>a.link').each do |lecture|
href = lecture.attr('href')
title = lecture.css('.value').first.attr('title')
page = Nokogiri::HTML(RestClient.get(HOST + href).body)
href = page.css('.srcFrom>a').first.attr('href')
system 'youtube-dl', '-o', 'title.%(ext)s', href
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment