是否可以在必应搜索 API 新闻中使用某种查询语言来获取例如标题中包含某些单词/短语的新闻?是否可以使用 AND、OR、near 等?你可以在这里看到操作员,我认为这会起作用: https ://msdn.microsoft.com/en-us/library/ff795620.aspx
我现在谈论的是 API 的第 5 版和第 7 版。
这是我写的代码来试试这个:
# below query is want I would like to have, which doesn't work
query_words = ['announce* near:4 win']
headers = {'Ocp-Apim-Subscription-Key': 'xxxx'}
b = 'https://api.cognitive.microsoft.com/bing/v5.0/news/search'
for w in query_words:
params = {"q": w, "count": "5", "mkt": "en-US", "category": "business", "freshness": "day"}
res = requests.get(b, params=params, headers=headers)
if res.status_code == 200:
articles = json.loads(res.content)