Javascript 限制Google自定义搜索引擎中的日期范围
我正在使用Google自定义搜索引擎()。我使用客户端脚本在html页面中创建搜索元素。代码如下所示:Javascript 限制Google自定义搜索引擎中的日期范围,javascript,seo,google-custom-search,Javascript,Seo,Google Custom Search,我正在使用Google自定义搜索引擎()。我使用客户端脚本在html页面中创建搜索元素。代码如下所示: <script> (function() { var cx = 'xxxxxxxxxxxxxxxxxx:yyyyy'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (do
<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>
(功能(){
变量cx='XXXXXXXXXXXXXXXX: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);
})();
它工作得很好,但我需要为用户添加一个选项来选择他们想要搜索的日期范围。例如“上个月”或“上个星期”
我看到人们正在谈论一个名为的参数作为_qdr
,可以为此设置为'm'或'w'。问题是,通过使用默认的javascript代码,我无法访问特定的API url来附加as_qdr=m
。我找不到任何关于如何做到这一点的好文档
如果你看一个例子,你就会明白我的意思。有一个选项可以选择结果的日期范围
有人以前做过这件事吗?
谢谢。我最终使用了他们的RESTful API。所以我自己设计了搜索表单,然后向谷歌查询结果