Skip to content

Instantly share code, notes, and snippets.

@thebigbad
Created August 5, 2012 07:10
Show Gist options
  • Save thebigbad/3262575 to your computer and use it in GitHub Desktop.
Save thebigbad/3262575 to your computer and use it in GitHub Desktop.
save random glitch image from flikr's glitches pool to file
#!/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