Skip to content

Instantly share code, notes, and snippets.

@gonglexin
Created April 28, 2010 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonglexin/382124 to your computer and use it in GitHub Desktop.
Save gonglexin/382124 to your computer and use it in GitHub Desktop.
Ruby::Download railscasts(markdown format)
require 'rss'
url = 'http://feeds.feedburner.com/railscasts'
rss = RSS::Parser.parse(url)
rss.items.reverse.each do |item|
puts "* [#{item.title}](#{item.enclosure.url})"
end
require 'net/http'
require 'uri'
baseurl = "http://railscasts.com"
page = Net::HTTP.get URI.parse('http://railscasts.com/episodes/archive')
match = page.scan /<a href=\"\/episodes.*>/
puts "You have #{match.length} episodes"
File.open('railscasts.html','w') do |f|
match.each do |data|
f.puts data.sub!(/\/episodes/,'http://media.railscasts.com/videos')\
.sub!(/\d+/) { |number| number.rjust(3, '0') }\
.gsub!(/-/,'_')\
.sub!(/\">/,'.mov">')\
<< '<br />'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment