Capturing a Moment in Time

Build a Google box for a particular moment in time.

Google boxes are a nice addition to your web pages, whether you run a weblog or a news site. But for many Google box searches, the search results won’t change that often, especially for more common search words. The Timely Google box—built upon the ordinary Google box [Hack #67] hack—captures a snapshot of newly indexed or reindexed material at a particular point in time.

Making the Google Box Timely

As you might remember, Google has a daterange: search syntax available. This version of Google box takes advantage of the daterange:[Hack #11] syntax, allowing you to specifying how many days back you want your query to run. If you don’t provide a number, the default is 1, and there’s no maximum. I wouldn’t go back much further than a month or so. The fewer days back you go the more often the results in the Google box will change.


You’ll need the Julian::Day module to get this hack rolling (

The Code

#!/usr/local/bin/perl # # A time-specific Google box # Usage: perl <query> <# results> <# days back> # Your Google API developer's key my $google_key='insert key here'; # Location of the GoogleSearch WSDL file my $google_wdsl = "./GoogleSearch.wsdl"; use strict; use SOAP::Lite; use Time::JulianDay; # Bring in those command-line arguments @ARGV == 3 or die "Usage: perl <query> <# results> <# days back>\n"; my($query, $maxResults, ...

Get Google Hacks now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.