问题
I am having a list of keywords and would like to know the number of results for google search for each of those(for my research project). I am using the below code for the same.
def showsome(searchfor):
hits = -1
try:
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']
print 'Total results for %s: %s' % (searchfor,data['cursor']['estimatedResultCount'])
hits = int(data['cursor']['estimatedResultCount'])
except:
#error.write(formatExceptionInfo())
traceback.print_exc(file=error)
error.write("\n")
return hits
But after some 1000 results, I am not getting any results. Is there an alternative way to query google? I checked google custom search API and it allows only 100 results per day.
来源:https://stackoverflow.com/questions/4785833/google-search-to-retrieve-number-of-results-for-search-keywords