必应新闻搜索API [英] bing news search API
问题描述
Bing新闻搜索API的新鲜度"参数如何工作?
How does the "freshness" parameter of the Bing news search API work?
我正在编写一个程序来调用Bing新闻搜索API. 我将新鲜度"参数设置为月".但是,必应返回的内容可能早于6个月前.我怎么知道的?我使用offset参数检索返回结果的最后一个新页面,发现它们可能长达6个月(甚至是2年odl).显然,此结果与我输入的fresness参数相矛盾.任何人都可以对此有所了解吗?非常感谢,
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,
以下是代码段: 基本上,我将新鲜度设置为月"(freshness = Month),然后按天对输出进行排序("sortBy = Day").
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,
}
推荐答案
将其移至答案中,已通过注释验证:
Moving this to the Answer as verified in comments:
问题在于& count设置为100.当前限制为50.正确设置此数字后,API将按预期工作.
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.
所以看起来像这样:
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,
这篇关于必应新闻搜索API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!