Created
September 10, 2010 19:29
-
-
Save hhutch/574217 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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