Skip to main content
nick.recoil.org
  1. Blog Archive/

Fetching Railscasts with Hpricot

In the spirit of why’s original nostrils , I’ve made a small Hpricot script to fetch me a set of screencasts from Railscasts

require 'rubygems'
require 'hpricot'
require 'open-uri'

uri='http://railscasts.com/episodes/'
from,to=*ARGV.map { |arg| arg.to_i }
(from..to).to_a.each do |ep|
  doc = Hpricot(open("#{uri}#{ep}"))
  puts (doc/'div.download').first.at('a')['href']
end

Then invoke by

ruby railscasts_downloader.rb 15 20 | xargs -n1 wget
Nick Ludlam
Author
Nick Ludlam
Creative Technologist