Created
November 16, 2016 10:57
-
-
Save diewland/ae4f2d493895681d8d7117865fa2fd98 to your computer and use it in GitHub Desktop.
Download flickr 100 photos from api
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
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