Skip to content

Instantly share code, notes, and snippets.

@bartvandendriessche
Created July 25, 2010 22:01
Show Gist options
  • Select an option

  • Save bartvandendriessche/489927 to your computer and use it in GitHub Desktop.

Select an option

Save bartvandendriessche/489927 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# script that will go over the railscasts website and create a list of
# all available videos. (can then be used to download using wget or
# something)
def has_downloads?(doc)
doc.css(".content").each do |content|
if content.text.include?("No episodes found. ")
return false
end
end
return true
end
def get_railscasts_page(page)
url = "http://railscasts.com/episodes?page=#{page}"
Nokogiri::HTML(open(url))
end
page = 1
begin
doc = get_railscasts_page page
doc.css(".download").each do |item|
puts item.at_css("a").attribute("href")
end
page += 1
end until not has_downloads? doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment