Skip to content

Instantly share code, notes, and snippets.

@andrei512
Created October 15, 2012 20:20
Show Gist options
  • Save andrei512/3895132 to your computer and use it in GitHub Desktop.
Save andrei512/3895132 to your computer and use it in GitHub Desktop.
sexy script
require 'nokogiri'
require 'open-uri'
album = "http://imgur.com/a/o37VA/layout/blog"
dom = Nokogiri::HTML(open(album))
base_name = "sexy"
index = 1
dom.xpath('//*[@id="image-container"]/div/div/a').each do |node|
link = node['href']
link["h.jpg"] = ".jpg"
print "downloading image from #{link} ..."
open("images/#{base_name}_#{index}.jpg", 'wb') do |file|
file << open(link).read
puts " done!"
end
index += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment