Created
December 9, 2014 14:56
-
-
Save jimr/4e122148e30fbb3d0ef5 to your computer and use it in GitHub Desktop.
flickr.py search pagination usage example
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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For pagination, you can either use the page count (from
photos_search_pages
) or just keep incrementing thepage
parameter until you run out of photos.