我在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 key
和endpoint
,因为我得到以下错误:
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'
你知道为什么没用吗?你知道吗
base_url
值应为:我已经在我这边测试过了,它对我很有效:
相关问题 更多 >
编程相关推荐