我正在尝试使用googlecustomsearch api来搜索图像,但奇怪的是,我通过api进行的搜索返回的结果与通过浏览器常规搜索的结果不同。例如
from apiclient.discovery import build
import pprint
import sys
api_key='xxxxxxx'
service = build('customsearch', 'v1', developerKey=api_key)
request=service.cse()
query=request.list(cx='xxxx:xxxxx',q='dogs and cats',searchType='image',imgType='photo')
result=query.execute()
pprint.pprint(result)
for i in result.get('items',[]):
print (i['link'])
运行这段代码会得到完全不同的结果 下面是运行上述代码的结果
^{pr2}$
这取决于您从google控制台创建的自定义搜索引擎。转到谷歌控制台上的CSE,尝试“在web上查看”选项,在浏览器中测试它,看看结果是否匹配。结果应该匹配。在
你正常的谷歌搜索将基于谷歌收集到的大量关于你的信息。在
你正常的谷歌搜索将基于谷歌收集到的大量关于你的信息。如果你退出google并使用一个匿名窗口,它应该不会受到影响。在
相关问题 更多 >
编程相关推荐