Skip to content

Instantly share code, notes, and snippets.

@diewland
Created November 16, 2016 10:57
Show Gist options
  • Save diewland/ae4f2d493895681d8d7117865fa2fd98 to your computer and use it in GitHub Desktop.
Save diewland/ae4f2d493895681d8d7117865fa2fd98 to your computer and use it in GitHub Desktop.
Download flickr 100 photos from api
import requests
import urllib
tag = 'person'
url = "https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=881cbcfeb398828ea12b253c1743224e&text=%s&format=json&nojsoncallback=1" % tag
proxies = {'http': 'http://your.proxy:port/'}
r = requests.get(url)
image = urllib.URLopener(proxies)
i = 1
for x in r.json()['photos']['photo']:
url = "http://farm%s.staticflickr.com/%s/%s_%s.jpg" % ( x['farm'], x['server'], x['id'], x['secret'] )
image.retrieve(url, "avatar_%s.jpg" % i)
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment