我怎么可以使用谷歌搜索API时输入日期限制? [英] how can I enter a date restriction when using the Google Search API?

查看:128
本文介绍了我怎么可以使用谷歌搜索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屋!

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