Jump to content

google search with date range


Recommended Posts

I would like to search google, limiting the date range to the past 2 years.

 

For example: (using g as a keyword)

g iphone apps 

 

The search should only show results from the past 2 years.

 

 

I had this working in alfred V1, but can't find anything under v2.  I'm sure it's my error. ;)

 

thanks!

Kevin

Edited by kevinapple
Link to comment

One way that you could do it is to have your workflow create the search string and just open the URL. Look at this string:

 

https://www.google.com/search?q=my+workflow+search&as_qdr=1y3m

 

So, the part before the ? is obvious.

 

q={input} is the query.

and as_qdr asks for the last results. Here the syntax is pretty obvious #y = number of years, #m = number of months, etc...

 

So, if you wanted to do what you did above and make it so it's always two years, then you'd grab the {query} and substitute "+" for " ". Then, you'd create the base URL:

 

http://www.google.com/search?q={parsed_query}

 

And then you'd append the time string: "&as_qdr=2y".

 

So, then you'd concatenate them to give you:

 

http://www.google.com/search?q={parsed_query}&as_qdr=2y

 

After that, you would just open the location in whatever browser you want.

 

If you want to show the results in Alfred, then you'll have to pull in the results in json or xml or something. Here's a really old blog post showing you how to use an API that is deprecated but still seems to work: http://googlesystem.blogspot.com/2008/04/google-search-rest-api.html.

 

Good luck.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...