经过多次尝试和搜索,以下Python代码成功调用了Google的搜索API,但只返回4个结果:在阅读Google搜索API文档后,我认为“start =”将返回更多结果:但实际上并没有发生这种情况。
有人能给出指针吗?谢谢。
Python代码:
/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']