使用Google自定义搜索API进行日期范围搜索 [英] Date range search using Google Custom Search API

查看:136
本文介绍了使用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("https://ajax.googleapis.com/ajax/services/search/images?"
                + "v=1.0&q=barack%20obama&userip=INSERT-USER-IP");

我将如何修改URL以将搜索结果限制为例如2014-08-152014-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.

此文档记录在 https://developers.google.com/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进行日期范围搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆