【问题标题】:Limit date range in Google Custom Search Engine在 Google 自定义搜索引擎中限制日期范围
【发布时间】:2015-06-27 08:31:05
【问题描述】:

我正在使用 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,您就会明白我的意思。可以选择结果的日期范围。

以前有人做过吗? 谢谢。

【问题讨论】:

    标签: javascript seo google-custom-search


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多