Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Created September 13, 2011 05:31
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save michaelficarra/1213190 to your computer and use it in GitHub Desktop.
Save michaelficarra/1213190 to your computer and use it in GitHub Desktop.
download all the listing images from a given etsy shop
require 'etsy'
Etsy.api_key = '<api-key>'
shop = Etsy::Shop.find '<shop-name>'
out_dir = '<output-directory>'
Etsy.environment = :production
Dir.mkdir out_dir unless File.exists? out_dir
listings = []
offset = 0
begin
nListings = listings.length
listings.concat Etsy::Listing.find_all_by_shop_id(shop.id, :limit => 100, :offset => offset)
offset += 100
end while listings.length > nListings
images = listings.map {|l| l.images.map {|i| i.full } }
images.flatten!
images.map do |image_url|
uri = URI.parse image_url
out_file = File.join out_dir, File.basename(uri.path)
unless File.exists? out_file
response = Net::HTTP.get_response uri
File.open(out_file, "w"){|f| f.write response.body }
end
end
@Queensesa
Copy link

someone who can help me with this? Pleaaaaase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment