我怎么可以使用谷歌搜索API时输入日期限制? [英] how can I enter a date restriction when using the Google Search API?
问题描述
我想使用谷歌的搜索API,并找到根据的事实,他们只是一个天大的结果。我能做到这一点,通过谷歌搜索引擎,但我似乎无法找到一种方法,通过使用API来做到这一点。
我的code:
$ googleFullURL = \"http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&start=$searchIndex&lr=lang_en&filter=0&q=$searchTerms\";
我试图用&放大器; TBS =,QDR:D我的搜索结束这是限制对日期范围时什么搜索引擎附加在URL的末尾,但是这似乎无法正常工作<。 / p>
感谢
您要使用的dateRestrict参数是一个字符串。
限制的结果根据日期的URL。支持的值包括:
- D [编号]:从过去几天的指定数量的请求结果
。
- W [编号]:从过去几周的指定数量的请求结果
。
- M [编号]:从过去几个月的指定数量的请求结果
。
- Y [编号]:从过去几年的指定数量的请求结果
。
块引用>有关参数文档: https://开头的开发。 google.com/custom-search/json-api/v1/reference/cse/list
I'm wanting to use the Google Search API and find results based on the fact that they are only a day old. I can do this through the Google search engine but I can't seem to find a way to do this by using the API.
my code: $googleFullURL = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&start=$searchIndex&lr=lang_en&filter=0&q=$searchTerms";
I tried using "&tbs=,qdr:d" at the end of my search which is what the search engine appends at the end of the URL when restricting to a date range but this seems to not be working.
thanks
解决方案You want to use the dateRestrict parameter which is a string.
Restricts results to URLs based on date. Supported values include:
- d[number]: requests results from the specified number of past days.
- w[number]: requests results from the specified number of past weeks.
- m[number]: requests results from the specified number of past months.
- y[number]: requests results from the specified number of past years.
Documentation for parameters: https://developers.google.com/custom-search/json-api/v1/reference/cse/list
这篇关于我怎么可以使用谷歌搜索API时输入日期限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!