gpt4 book ai didi

javascript - 限制 Google 自定义搜索引擎中的日期范围

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:44:23 25 4
gpt4 key购买 nike

我正在使用 Google 自定义搜索引擎 ( https://cse.google.com )。我使用客户端脚本在我的 html 页面中创建一个搜索元素。代码如下所示:

<script>
(function() {

var cx = 'xxxxxxxxxxxxxxxxxx:yyyyy';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchresults-only></gcse:searchresults-only>

它工作正常,但我需要添加一个选项供用户选择他们想要搜索的日期范围。例如“过去一个月”或“过去一周”...

我看到人们在谈论一个名为 as_qdr 的参数,为此可以将其设置为“m”或“w”。问题是,通过使用默认的 javascript 代码,我无权访问特定的 API url 以将 as_qdr=m 附加到。我找不到关于如何执行此操作的任何好的文档。

如果你看一下http://www.reuters.com/search/news?blob=test例如你会明白我的意思。可以选择结果的日期范围。

有没有人做过这个?谢谢。

最佳答案

我最终使用了他们的 RESTful API。所以我自己设计了搜索表单,然后向 Google 查询结果。

https://developers.google.com/custom-search/json-api/v1/overview

关于javascript - 限制 Google 自定义搜索引擎中的日期范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29750874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com