Last active
January 1, 2016 10:49
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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