By default, the Google+ APIs return a maximum of 25 results, but we can extend the previous scripts by increasing the maximum value and harvesting more results through pagination. As before, we will communicate with the Google+ API through a URL and the urllib
library. We will create arbitrary numbers that will increase as requests go ahead, so we can move across pages and gather more results.
The following script shows how you can harvest additional results from the Google+ API:
import urllib2 import json GOOGLE_API_KEY = "{Insert your Google API key}" target = "packtpub.com" token = "" loops = 0 while loops < 10: api_response = urllib2.urlopen("https://www.googleapis.com/plus/v1/people? query="+target+"&key="+GOOGLE_API_KEY+"&maxResults=50& pageToken="+token).read() json_response = json.loads(api_response) token = json_response['nextPageToken'] if len(json_response['items']) == 0: ...