Collecting some photo information from Flickr using REST
Many Internet websites provide a web services interface through their REST APIs. Flickr, a famous photo sharing website, has a REST interface. Let's try to gather some photo information to build a specialized database or other photo-related applications.
To run this recipe, you need to install requests
using pip:
$ sudo pip install requests
How to do it...
We need the REST URLs for making the HTTP requests. For simplicity's sake, the URLs are hard coded in this recipe. We can use the third-party requests module to make the REST requests. It has the convenient GET()
, POST()
, PUT()
, and DELETE()
methods.
In order to talk to Flickr web services, you need to register yourself and get a secret API key. This API key can be placed in a local_settings.py
file or supplied through the command line.
Listing 7.4 gives the code for collecting some photo information from Flickr using REST, as shown:
#!/usr/bin/env python # Python Network Programming Cookbook...