ike*_*kel 12 python search google-api python-3.x google-custom-search
我正在尝试google customsearch 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'])
Run Code Online (Sandbox Code Playgroud)
运行此代码会产生完全不同的结果,这是运行上面代码的结果
https://s.yimg.com/ny/api/res/1.2/tarWzt2ZXfPOEg8oQVlOWw--/YXBwaWQ9aGlnaGxhbmRlcjtzbT0xO3c9ODAw/http://media.zenfs.com/en-US/homerun/people_218/4d82a5fa19dd37247717704975fdf602
https://www.google.com/about/main/machine-learning-qa/img/cat-dog-flow-horizontal.gif
https://www.google.com/trends/2014/static/images/pets-snapshot-reveal-1920.jpg
https://www.google.com/trends/2014/static/images/pets-share.png
https://www.google.com/about/main/machine-learning-qa/img/cat-dog-flow-vertical.gif
https://s.yimg.com/uu/api/res/1.2/YQWuQgTnzQuwXjYzX.QrWg--~B/aD0xMzMzO3c9MjAwMDtzbT0xO2FwcGlkPXl0YWNoeW9u/http://media.zenfs.com/en-US/homerun/people_218/4d82a5fa19dd37247717704975fdf602
https://www.google.com/trends/2014/static/images/pets-video-1080.jpg
https://www.google.com/trends/2014/static/images/pets-video-320.jpg
https://www.google.com/maps/d/thumbnail?mid=1hO0YkGLATyy-ZI9JxX1lbv-wK1M&hl=en_US
Run Code Online (Sandbox Code Playgroud)
这取决于您从Google控制台创建的自定义搜索引擎。在您的Google控制台上转到CSE,然后尝试“在网络上查看”选项,以在您的浏览器中对其进行测试以及结果是否匹配。结果应该匹配。
| 归档时间: |
|
| 查看次数: |
813 次 |
| 最近记录: |