Thursday, March 26, 2009

DBD::Google - Treat Google as a datasource for DBI

Somehow all of our information ends up on Google. Now we can treat Google like a database and query it with SQL just like a simple database:

#!/usr/bin/perl -w

use strict;
use warnings 'all';
use DBI;
use Data::Dumper;

my $key = 'ABQIAAA...-P_bCg';
my $dbh = DBI->connect("dbi:Google:", $key);
my $sth = $dbh->prepare('SELECT title, URL FROM google WHERE q = "perl"');
while( my $rec = $sth->fetchrow_hashref )
warn Dumper( $rec );
}# end while()

Unfortunately, it requires you to get a Google SOAP API Key, which Google no longer supports.

Perhaps the author, Darren Chamberlain, will consider upgrading DBD::Google to use REST::Google or something similar instead.

Here's to hoping :-)