Skip to content

Instantly share code, notes, and snippets.

@benschwarz
Created July 2, 2009 04:57
Show Gist options
  • Save benschwarz/139275 to your computer and use it in GitHub Desktop.
Save benschwarz/139275 to your computer and use it in GitHub Desktop.
# Download images from ffffound and add to random desktop images.
# Install:
# Add to cron
# Create "FFFFound" directory in ~/Pictures/
# Happiness ensues
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'fileutils'
module FFFFound
class << self
def find
dispatch!
doc = Nokogiri::HTML(@response)
doc.css("img[@id*='asset']").map do |img|
img.attributes['src']
end
end
private
def dispatch!
@response = open('http://ffffound.com')
end
end
end
FFFFound.find.each do |img|
path = "/Users/#{`whoami`.strip!}/Pictures/FFFFound/"
save_path = path + File.basename(img)
unless File.exists? save_path
puts "Downloading #{img}"
File.open(save_path, 'w') {|f| f.write(open(img).read) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment