经过大量的实验和Google搜索,下面的Python代码成功地调用了Google的搜索APi,但是只返回了4个结果:在阅读了Google searchapi文档之后,我认为“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']
start选项并没有给你更多的结果,它只是让你前进了那么多的结果。把结果想象成一个队列。从50开始将得到50、51、52和53的结果。在
使用此选项,您可以通过每隔4个结果开始获得更多结果:
相关问题 更多 >
编程相关推荐