Azure认知服务中未找到资源

2024-05-20 19:35:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我在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 \"")

但是,脚本似乎没有正确读取generaedSubscription keyendpoint,因为我得到以下错误:

File "azu_scrapper.py", line 17, in web_data = client.web.search(query="Yosemite") File "/home/user/.local/share/virtualenvs/linkedin-CHSAGU1d/lib/python3.7/site-packages/azure/cognitiveservices/search/websearch/operations/web_operations.py", line 365, in search raise models.ErrorResponseException(self._deserialize, response) azure.cognitiveservices.search.websearch.models.error_response_py3.ErrorResponseException: Operation returned an invalid status code 'Resource Not Found'

你知道为什么没用吗?你知道吗


Tags: thekeyfromimportclientwebsearchmodels