Google Search API - Only returning 4 results

Posted by user353829 on Stack Overflow See other posts from Stack Overflow or by user353829
Published on 2010-12-22T04:30:15Z Indexed on 2011/01/06 4:53 UTC
Read the original article Hit count: 236

After much experimenting and googling, the following Python code successfully calls Google's Search APi - but only returns 4 results: after reading the Google Search API docs, I thought the 'start=' would return additional results: but this not happen.

Can anyone give pointers? Thanks.

Python code:

/usr/bin/python
import urllib
import simplejson

query = urllib.urlencode({'q' : 'site:example.com'})
url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&%s&start=50' \
  % (query)
search_results = urllib.urlopen(url)
json = simplejson.loads(search_results.read())
results = json['responseData']['results']
for i in results:
  print i['title'] + ": " + i['url']

© Stack Overflow or respective owner

Related posts about python

Related posts about google-search