Created
August 5, 2012 07:10
-
-
Save thebigbad/3262575 to your computer and use it in GitHub Desktop.
save random glitch image from flikr's glitches pool to file
This file contains hidden or 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 characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'open-uri' | |
index_url = 'http://www.flickr.com/groups/glitches/pool/' | |
index = Nokogiri::HTML(open(index_url)) | |
image_urls = index.css('a[class="rapidnofollow"] img').to_a | |
image_url = image_urls[rand(image_urls.length)]['src'] | |
image = File.open(ARGV.first, 'wb') | |
image << open(image_url).read |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment