Skip to content

Instantly share code, notes, and snippets.

@akiym
Created April 28, 2011 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akiym/945998 to your computer and use it in GitHub Desktop.
Save akiym/945998 to your computer and use it in GitHub Desktop.
Google CGI API for Japanese Input
use strict;
use warnings;
use Encode;
use JSON;
use LWP::UserAgent;
use URI;
use Data::Dumper;
use Data::Recursive::Encode;
my $text = shift or die;
my $uri = URI->new('http://www.google.com/transliterate');
$uri->query_form(langpair => 'ja-Hira|ja', text => $text);
my $ua = LWP::UserAgent->new();
my $res = $ua->get($uri);
my $json = $res->content;
my $content = JSON->new->relaxed(1)->decode($json);
warn Dumper(Data::Recursive::Encode->encode_utf8($content));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment