Skip to content

Instantly share code, notes, and snippets.

@zer0her0
Forked from rudle/gist:1056111
Created July 1, 2011 15:33
Show Gist options
  • Save zer0her0/1058783 to your computer and use it in GitHub Desktop.
Save zer0her0/1058783 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'nokogiri'
require 'httparty'
doc = Nokogiri(HTTParty.get('http://www.gutenberg.org/wiki/Harvard_Classics_(Bookshelf)'))
ids = doc.css('a').select{|a| a.attr('title') =~ /ebook:/ }.map do |a|
a.attr('title') =~ /ebook:(\d+)/
{:title => a.text, :id => $1 }
end.compact.uniq
ids.each do |book|
sleep 2
File.open("/tmp/gutenberg/#{book[:id]}-#{book[:title]}", "w+") do |file|
file << HTTParty.get("http://gutenberg.org/ebooks/#{book[:id]}.kindle.noimages")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment