大家好,我們正在使用谷歌API如這個'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&%s'通過python腳本查詢,但非常快,它被阻止。任何解決此問題的方法?謝謝。Google API限制克服
以下是我目前的代碼。
#!/usr/bin/env python
import math,sys
import json
import urllib
def gsearch(searchfor):
query = urllib.urlencode({'q': searchfor})
url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&%s' % query
search_response = urllib.urlopen(url)
search_results = search_response.read()
results = json.loads(search_results)
data = results['responseData']
return data
args = sys.argv[1:]
m = 45000000000
if len(args) != 2:
print "need two words as arguments"
exit
n0 = int(gsearch(args[0])['cursor']['estimatedResultCount'])
n1 = int(gsearch(args[1])['cursor']['estimatedResultCount'])
n2 = int(gsearch(args[0]+" "+args[1])['cursor']['estimatedResultCount'])
我已添加我的代碼。我不立即跑,我暫停每一次運行。 – user2711681