Skip to content

Instantly share code, notes, and snippets.

@adam
Created February 22, 2009 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam/68597 to your computer and use it in GitHub Desktop.
Save adam/68597 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'uri'
require 'open-uri'
require 'hpricot'
require 'net/http'
require 'ftools'
## it's pretty disgusting that that I require this many things. Someone fork me and fix me.
URL = "http://www.socwall.com/php/rss_RecentWPs.php" # widescreen pictures
DIR = "/path/to/wherever/you/want/to/put/the/pictures"
doc = Hpricot(open(URL))
(doc/"item/guid").each do |photo|
uri = URI.parse(photo.inner_html.strip.gsub(" ", "%20"))
filename = uri.path.split("/").last
`cd #{DIR} && curl -sO #{uri.to_s}` unless File.exists?(File.join(DIR, filename))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment