Last active
September 12, 2016 18:04
-
-
Save trakhov/8769839 to your computer and use it in GitHub Desktop.
This ruby script downloads a random photo from flickr.com (search by "1680x1050" and "nature" tags).
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
require 'flickraw' | |
require 'open-uri' | |
FlickRaw.api_key="your api key" | |
FlickRaw.shared_secret="your secret" | |
args = { | |
tags: "1680x1050,nature", | |
tag_mode: "all", | |
per_page: 500, | |
# page: 2, | |
} | |
while true | |
pictures = flickr.photos.search(args).to_a | |
pic = pictures.sample | |
info = flickr.photos.getInfo(photo_id: pic['id']) | |
break if info.respond_to? :originalsecret | |
end | |
open(FlickRaw.url_o info) do |src| | |
binary = src.read | |
open("your path here/flickr.jpg", 'wb') { |f| f.write binary } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment