使用Google自定义搜索API进行日期范围搜索

编程入门 行业动态 更新时间:2024-10-14 02:25:02
本文介绍了使用Google自定义搜索API进行日期范围搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Google自定义搜索API搜索图像.我的实现使用Java,这就是我构建搜索字符串的方式:

I am using the Google Custom Search API to search for images. My implementation is using Java, and this is how I build my search string:

URL url = new URL("ajax.googleapis/ajax/services/search/images?" + "v=1.0&q=barack%20obama&userip=INSERT-USER-IP");

我将如何修改URL以将搜索结果限制为例如2014-08-15和2014-09-31?

How would I modify the URL to limit search results, for example, to: 2014-08-15 and 2014-09-31?

推荐答案

您可以使用sort参数指定日期范围.对于您的示例,您可以将其添加到查询字符串:sort=date:r:20140815:20140931.

You can specify a date range using the sort parameter. For your example, you would add this to your query string: sort=date:r:20140815:20140931.

此文档记录在 developers.google/custom-搜索/docs/structured_data#page_dates

此外,如果您使用Google的Java API,则可以使用Query类及其setSort()方法,而不是手动构建URL.

Also if you use Google's Java API you can use the Query class and its setSort() method rather than building the URL by hand.

更多推荐

使用Google自定义搜索API进行日期范围搜索

本文发布于:2023-11-28 12:34:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642416.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   日期   Google   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!