Skip to content

Instantly share code, notes, and snippets.

@hhutch
Created September 10, 2010 19:29
Show Gist options
  • Save hhutch/574217 to your computer and use it in GitHub Desktop.
Save hhutch/574217 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
# Continually query google scribe using the first result returned creating abstract collective sub-conscious poetry
use LWP::Simple;
use JSON;
sub get_scribble {
my ($query, $last_sel) = @_;
my $cnt = get("http://scribe.googlelabs.com/suggest?client=gs&hl=en&q=".URI->new($query)."&s=c&callback=gsjc2");
if ($cnt) {
$|=1; # flush buffer
$cnt =~ s/^gsjc2.\&\&.gsjc2\((.*)\)$/\1/;
my $pv = decode_json $cnt;
print $pv->[1]->[0]->[4];
$query = $pv->[1]->[0]->[0];
$last_sel = $pv->[1]->[0]->[3];
} else {
$query = $last_sel;
}
get_scribble($query, $last_sel);
}
$query = (@ARGV)?join(" ",@ARGV):"matt sa";
print $query;
get_scribble($query);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment