Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

Queensesa commented Jul 28, 2021

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