Skip to content

Instantly share code, notes, and snippets.

@ideamonk
Created November 11, 2009 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ideamonk/231856 to your computer and use it in GitHub Desktop.
Save ideamonk/231856 to your computer and use it in GitHub Desktop.
This is a python script that Yuvi wrote, comes handy while making a collection for pymos
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Download with wget and xargs
# python download.py portrait 1 | xargs wget --directory-prefix=pics
# first argument is tag name, second is page number. 500 pics per page.
# -- Yuvi Panda
import sys
import simplejson as json
from urllib2 import urlopen
from urllib import urlencode
API_KEY = '9cd766b1c8a0e3196a9c2d2f7cb4cb01'
request_info = {'method':'flickr.photos.search',
'license':'4,2,1,5,7',
'sort':'interestingness-desc',
'extras':'url_s,owner_name',
'per_page':'500',
'format':'json',
'nojsoncallback':'1',
}
request_info['tag'] = sys.argv[1]
request_info['page'] = sys.argv[2]
request_info['api_key'] = API_KEY
url = 'http://api.flickr.com/services/rest/?' + urlencode(request_info)
response = urlopen(url).read()
data = json.loads(response)
photos = data['photos']['photo']
for p in photos:
print p['url_s']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment