bing新闻搜索API

问题描述 投票:2回答:1

Bing新闻搜索API的“新鲜度”参数如何工作?

我正在编写一个程序来调用Bing新闻搜索API。我将“新鲜度”参数设置为“月”。然而,Bing返回的内容可能与6个月前一样久远。我是怎么知道的?我使用offset参数来检索返回结果的最后一个新页面,并发现它们可以长达6个月(有些甚至是2年的odl)。 Clarly,这个结果与我放入的fresness参数相矛盾。任何人都可以对此有所了解吗?非常感谢,

以下是代码片段:基本上,我将新鲜度设置为Month(fresh = Month)并按天排序输出(sortBy = Day)。

   let bing_news_search = function (search) {
console.log('Searching news for: ' + term);
let request_params = {
    method: 'GET',
    hostname: host,
    path: path + '?q=' + encodeURIComponent('Microsoft') +'&count=100'+'&freshness=Month'+'&sortBY=Date'+'&offset=4979900',
    headers: {
        'Ocp-Apim-Subscription-Key': subscriptionKey,
    } 
azure microsoft-cognitive bing bing-api
1个回答
1
投票

将此内容移至评论中已验证的答案:

问题是&count设置为100.当前限制为50.一旦正确设置此数字,API将按预期工作。

所以它看起来像这样:

 let bing_news_search = function (search) {
console.log('Searching news for: ' + term);
let request_params = {
    method: 'GET',
    hostname: host,
    path: path + '?q=' + encodeURIComponent('Microsoft') +'&count=50'+'&freshness=Month'+'&sortBY=Date'+'&offset=4979900',
    headers: {
        'Ocp-Apim-Subscription-Key': subscriptionKey,
© www.soinside.com 2019 - 2024. All rights reserved.