我正在尝试使用https://github.com/tristantao/py-bing-search中的PyBingSearch模块来使用Bing API返回搜索结果。在github页面中,他们有一个如何使用它的例子。
from py_bing_search import PyBingWebSearch
search_term = "Python Software Foundation"
bing_web = PyBingWebSearch('Your-Api-Key-Here', search_term, web_only=False) # web_only is optional, but should be true to use your web only quota instead of your all purpose quota
first_fifty_result= bing_web.search(limit=50, format='json') #1-50
当我尝试运行声明first_fifity_result
的行时,我收到一条错误,指出Request returned with code 401, error msg: The authorization type you provided is not supported. Only Basic and OAuth are supported
为什么会出现此错误?在我的代码中,我确保将Your-Api-Key-Here
更改为我的API密钥。
答案 0 :(得分:0)
您是否更换了API密钥?在哪里说“你的API-Key-Here”
bing_web = PyBingWebSearch('Your-Api-Key-Here', search_term, web_only=False) # web_only is optional, but should be true to use your web only quota instead of your all purpose quota