Created
June 27, 2010 00:43
-
-
Save spicycode/454499 to your computer and use it in GitHub Desktop.
Revisions
-
spicycode created this gist
Jun 27, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ #!/usr/bin/env ruby require 'fileutils' require 'pp' include FileUtils FileUtils.mkdir_p('images') unless File.exist?('images') FileUtils.rm_rf('dribbble.html') if File.exist?('dribbble.html') FileUtils.rm_rf('dribbble.rss') if File.exist?('dribbble.rss') FileUtils.rm_rf('download_me.txt') if File.exist?('download_me.txt') ExtractImageRegex = /src=\"([^\"]+)\"/im DribbleUrl = 'http://dribbble.com/shots/everyone.rss' system "curl #{DribbleUrl} -o dribbble.rss" rss = File.readlines('dribbble.rss', 'r').join("").split("<") all_images, images = [], [] rss.each do |line| ExtractImageRegex.match(line) all_images << $1 end all_images.compact! all_images.each do |i| local_file = i.split('/').last images << i unless File.exist?("images/#{local_file}") end File.open("download_me.txt", "w") do |f| f << images.join("\n") end system "wget --input-file=download_me.txt --directory-prefix=images" html = "<html><head>" html << "<title>Dribble Gallery</title>" html << "<style>" html << "body { background-color: #c7c7c7; }" html << "</style>" html << "</head><body>" Dir["images/*"].each do |file| html << "<img src=\"#{file}\" border=\"0\" width=\"400\" height=\"300\" />" end html << "</body></html>" File.open("dribbble.html", "w") { |f| f << html }