Skip to content

Instantly share code, notes, and snippets.

@kitallis
Last active January 1, 2016 10:49
Show Gist options
  • Save kitallis/8133580 to your computer and use it in GitHub Desktop.
Save kitallis/8133580 to your computer and use it in GitHub Desktop.
download all the egon schiele paintings from http://www.doc.ic.ac.uk/~svb/Schiele/
require 'nokogiri'
require 'open-uri'
BASE_PATH = 'http://www.doc.ic.ac.uk/~svb/Schiele'
html_doc = Nokogiri::HTML(open(BASE_PATH) { |url| url.read })
html_doc.xpath('//td//a', 'align' => 'center').each do |image_element|
image_name = image_element.values.first
next if File.file?(image_name)
download_path = File.join(BASE_PATH, image_name)
puts "Downloading image – #{download_path}\n"
open(download_path) { |image| File.open(image_name, 'wb') { |file| file.puts(image.read) } }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment