问题
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");
How would I modify the URL to limit search results, for example, to: 2014-08-15
and 2014-09-31
?
回答1:
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
.
This is documented at https://developers.google.com/custom-search/docs/structured_data#page_dates
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.
来源:https://stackoverflow.com/questions/32406933/date-range-search-using-google-custom-search-api