Created
September 6, 2014 16:42
-
-
Save marktyers/c23c3d8042ba808b86e5 to your computer and use it in GitHub Desktop.
Searching Flickr
This file contains 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 json | |
key = '<YOUR FLICKR API KEY>' | |
url = 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key='+key+'&tags=coventry&format=json&nojsoncallback=1' | |
response = urllib2.urlopen(url).read() | |
data = json.loads(response.decode('utf8')) | |
photos = data['photos']['photo'] | |
for photo in photos: | |
url = 'https://farm'+str(photo['farm'])+'.staticflickr.com/'+str(photo['server'])+'/'+photo['id']+'_'+photo['secret']+'_q.jpg' | |
print(photo['title']) | |
print(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment