Python Network Programming
by Abhishek Ratan, Eric Chou, Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker
How it works...
This recipe demonstrates how to interact with Flickr using its REST APIs. In this example, the collect_photo_info() tag takes three parameters: Flickr API key, a search tag, and the desired number of search results.
We construct the first URL to search for photos. Note that in this URL, the value of the method parameter is flickr.photos.search and the desired result format is JSON.
The results of the first GET() call are stored in the resp variable and then converted to the JSON format by calling the json() method on resp. Now, the JSON data is read in a loop looking into the ['photos']['photo'] iterator. A photo_collection list is created to return the result after organizing the information. In this list, each photo's information ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access