【问题标题】:Resource not found on Azure Cognitive Services在 Azure 认知服务上找不到资源
【发布时间】:2020-03-15 04:23:54
【问题描述】:

我在the tutorial 1 之后创建了一个 Azure 认知服务资源

然后我创建了环境并运行以下代码(来自tutorial 2):

# Import required modules.
from azure.cognitiveservices.search.websearch import WebSearchAPI
from azure.cognitiveservices.search.websearch.models import SafeSearch
from msrest.authentication import CognitiveServicesCredentials

# Replace with your subscription key.
subscription_key = "YOUR_SUBSCRIPTION_KEY"

# Instantiate the client and replace with your endpoint.
client = WebSearchAPI(CognitiveServicesCredentials(subscription_key), base_url = "YOUR_ENDPOINT")

# Make a request. Replace Yosemite if you'd like.
web_data = client.web.search(query="Yosemite")
print("\r\nSearched for Query# \" Yosemite \"")

但是,由于出现以下错误,脚本似乎无法正确读取生成的 Subscription keyendpoint

文件“azu_scrapper.py”,第 17 行,在 web_data = client.web.search(query="Yosemite") 文件“/home/user/.local/share/virtualenvs/linkedin-CHSAGU1d/lib/python3.7/site-packages/azure/cognitiveservices/search/websearch/操作/web_operations.py", 第 365 行,正在搜索中 引发models.ErrorResponseException(self._deserialize,响应)azure.cognitiveservices.search.websearch.models.error_response_py3.ErrorResponseException: 操作返回无效的状态代码“未找到资源”

知道为什么它不起作用吗?

【问题讨论】:

    标签: python azure microsoft-cognitive azure-cognitive-search


    【解决方案1】:

    base_url 值应该是:

    https://<your endpoint>/bing/v7.0
    

    我已经测试过,它对我有用:

    【讨论】:

    • 太棒了!就是这样!!
    • 嗨@Alvaro,很高兴知道您的问题已经解决,请将此标记为答案,以便其他有类似问题的人有所帮助,谢谢!
    猜你喜欢
    • 2020-12-26
    • 1970-01-01
    • 2020-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-14
    相关资源
    最近更新 更多