bing news search API

为君一笑 提交于 2019-12-11 03:24:48

问题


How does the "freshness" parameter of the Bing news search API work?

I am writng a program to call the Bing news search API. I set the "freshness" parameter to be "Month". Yet, Bing returned content that can be as old as 6 months ago. How did I find out? I use the offset parameter to retrieve the last new pages of the returned result and found out that they are can be as old as 6 months (some even 2 years odl). Clarly, this result is contradict to the fresness parameter that I put in. Can anyone shed some light on this? Many thanks,

The following is the code snippet: Basically, I set the freshness to be Month (freshness=Month) and sort the output by day (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,
    } 

回答1:


Moving this to the Answer as verified in comments:

The issue is that the &count is set to 100. The current limit is 50. Once setting this number correctly the API will work as expected.

So it will look like so:

 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,


来源:https://stackoverflow.com/questions/48934933/bing-news-search-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!