There is a 'search outside of google'checkbox in the dashboard. you will get the same result after you check it. it takes me a while to find it out. the default sitting is only return search result inside of all google websites.
google custom search api return is different from google.com
-
13-07-2023 - |
Pergunta
I am using google api via python and it works, but the result I got from api is totally different from google.com. I found the top result given by custom search are google calendar,google earth and patents. I wonder if there is a way to get same result from custom search api. Thank you
def googleAPICall(self,userInput):
try:
userInput = urllib.quote(userInput)
for i in range(0,1):
index = i*10+1
url = ('https://www.googleapis.com/customsearch/v1?'
'key=%s'
'&cx=%s'
'&alt=json'
'&num=10'
'&start=%d'
'&q=%s')%(self.KEY,self.CX,index,userInput)
print (url)
request = urllib2.Request(url)
response = urllib2.urlopen(request)
returnResults = simplejson.load(response)
webs = returnResults['items']
for web in webs:
self.result.append(web["link"])
except:
print ("search error")
self.result.append("http://en.wikipedia.org/wiki/Climate_change")
return self.result
Solução
Outras dicas
After some searches, the answer is "It is impossible to have the same result as google.com".
Google clearly stated it: https://support.google.com/customsearch/answer/141877?hl=en
Hope that this is the definite answer.
I think you need to experiment with four parameters cr, gl, hl, lr
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow