Skip to content

Instantly share code, notes, and snippets.

@benschwarz
Created December 2, 2008 04:31
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 benschwarz/30996 to your computer and use it in GitHub Desktop.
Save benschwarz/30996 to your computer and use it in GitHub Desktop.
RubyConf 2008 video scraper
%w(rubygems nokogiri open-uri fileutils).each do |r|
require r
end
BASE_URI = "http://rubyconf2008.confreaks.com/"
LOCAL_SAVE_PATH = "ruby-videos/"
FileUtils.mkdir_p LOCAL_SAVE_PATH
puts "Looking..."
doc = Nokogiri::HTML(open(BASE_URI))
video_pages = doc.css('td.program a').map{|element| element.attributes['href'] }
puts "Hunting and gathering..."
videos = video_pages.uniq.map do |page|
puts "\tFound #{File.basename(page)}!"
vid_doc = Nokogiri::HTML(open(BASE_URI + page))
vid_doc.css('.formatlist a').first.attributes['href']
end
puts "Downloading..."
videos.each do |vid_path|
puts "\tDownloading #{vid_path}..."
unless File.exists? LOCAL_SAVE_PATH + File.basename(vid_path)
File.open(LOCAL_SAVE_PATH + File.basename(vid_path), 'w') {|f| f.write(open(BASE_URI + vid_path).read) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment