python - Azure Bing 图像搜索客户端抛出未找到资源
问题描述
我正在尝试使用 bing 图片搜索 SDK,但本教程不适用于我:
from azure.cognitiveservices.search.imagesearch import ImageSearchClient
from msrest.authentication import CognitiveServicesCredentials
# This is my key generated by azure portal
subscription_key = "XXXXXXXXXXXXXXXXX"
# This is my endpoint generated by azure portal
subscription_endpoint = "https://vadmeggy-image-search.cognitiveservices.azure.com/bing/v7.0"
search_term = "bird"
client = ImageSearchClient(endpoint=subscription_endpoint, credentials=CognitiveServicesCredentials(subscription_key))
image_results = client.images.search(query=search_term)
例外:
azure.cognitiveservices.search.imagesearch.models._models_py3.ErrorResponseException: Operation returned an invalid status code 'Resource Not Found'
我错过了什么?我调用了 REST API,它与给定的订阅密钥配合得很好。如果 SDK 不起作用,我可以回退到 REST API,但也许有人可以帮助我。
解决方案
Python实现自动添加必应版本,需要使用
subscription_endpoint = "https://vadmeggy-image-search.cognitiveservices.azure.com"
一切都会好起来的。似乎文档和实现不同步。
推荐阅读
- node.js - Jest 对期望值的隐式类型检查
- node.js - 构建有角度的电子应用程序时,“在后台线程内存不足后返回 API 致命错误处理程序”
- java - 教孩子简单加减法的Java程序
- javascript - 使用 Vuetify.js 的右上角菜单
- python-2.7 - 使用 pyinstaller 构建 arm64 目标构建
- css - 试图并排放置 2 个不同的 div
- rethinkdb - RethinkDB如何删除列表中的重复值,最新值除外
- php - 目标类[ProductController]在laravel 8中不存在错误。路由的写法不同
- java - 命运之轮统计模拟java
- docker - 为什么 minikube 本身作为容器运行?