Skip to content

Instantly share code, notes, and snippets.

@swdyh
Created February 11, 2009 17:43
Show Gist options
  • Select an option

  • Save swdyh/62135 to your computer and use it in GitHub Desktop.

Select an option

Save swdyh/62135 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# download images from http://www.muji.net/2009ss/women/
require 'fileutils'
require 'open-uri'
dir = 'muji2009ss_w'
FileUtils.mkdir_p dir
puts "create: #{dir}"
html = '<html><body>'
urls = (1..87).map do |i|
url = 'http://www.muji.net/2009ss/women/img/0902w_%02d.jpg' % i
path = File.join(dir, url.split('/').last)
puts "download: #{url}"
open(path, 'w') { |f| f.write(open(url).read) }
html << ('<a href="%s"><img src="%s" style="border:0;" /></a>' % [url, path])
sleep 1
end
html << '</body></html>'
html_path = "#{dir}.html"
open(html_path, 'w') { |f| f.puts html }
puts "create: #{html_path}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment