Created
September 9, 2013 14:07
-
-
Save bknarendra/6496065 to your computer and use it in GitHub Desktop.
Download all railscasts videos
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
require 'mechanize' | |
a = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari'} | |
url=your_subscription_url | |
doc=nil | |
a.get url | |
for i in 1..420 | |
begin | |
url="http://railscasts.com/episodes/#{i}" | |
a.get url do |page| | |
doc=page.parser | |
dir=doc.css('title')[0].text.gsub(/[^a-zA-Z0-9 ]/,"").gsub(/ /,"_") | |
Dir.mkdir(dir,0755) | |
puts %x(cd #{dir} && wget #{doc.css('a:contains("source code")')[0]["href"]}) if doc.css('a:contains("source code")').length > 0 | |
puts %x(cd #{dir} && wget #{doc.css('a:contains("mp4")')[0]["href"]}) if doc.css('a:contains("mp4")').length > 0 | |
end | |
rescue Exception => e | |
puts e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment