Date range search using Google Custom Search API

£可爱£侵袭症+ 提交于 2019-12-01 04:53:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!