Skip to content

Instantly share code, notes, and snippets.

@jimr
Created December 9, 2014 14:56
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 jimr/4e122148e30fbb3d0ef5 to your computer and use it in GitHub Desktop.
Save jimr/4e122148e30fbb3d0ef5 to your computer and use it in GitHub Desktop.
flickr.py search pagination usage example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import flickr
flickr.API_KEY = '<your API key>'
flickr.API_SECRET = '<your API secret>'
page = 1
per_page = 10
print '{} pages of photos in total'.format(
flickr.photos_search_pages(tags="manhattan", per_page=per_page)
)
while True:
photos = flickr.photos_search(tags="manhattan", per_page=per_page, page=page)
if not len(photos):
break
print "{} photos on page {}".format(len(photos), page)
page += 1
@jimr
Copy link
Author

jimr commented Dec 9, 2014

For pagination, you can either use the page count (from photos_search_pages) or just keep incrementing the page parameter until you run out of photos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment