#!/usr/local/bin/perl -T use strict; use warnings; use Encode; use CGI; use LWP::Simple; use XML::Simple; use HTML::Template; use URI::Escape; use utf8; binmode STDOUT, ":utf8"; my $q = new CGI; my $key = $q->param('key') || ""; my $sr_ref = yapi({key => $key}); my $template = join("", ); my $t = HTML::Template->new(scalarref => \$template, die_on_bad_params => 0); $t->param(key => decode('utf-8', $key)); $t->param(results => $sr_ref); print $q->header(-charset => 'UTF-8'), $t->output(); sub yapi { my ($args_ref) = @_; my $key = $args_ref->{key}; return [] unless $key; my $ec = URI::Escape::uri_escape($key); my $url = "http://boss.yahooapis.com/ysearch/web/v1/$ec?" ."appid=gt33JKTV34FKDv3AXuxs6ZC8prX.uGFZKZnOa3CqrH9dMpgz2HAVEqIoZ3vv2URI27IEDg--&" ."format=xml&lang=jp®ion=jp"; my $response = get($url); my $xmlsimple = XML::Simple->new(ForceArray => [ 'result' ]); my $xml = $xmlsimple->XMLin($response); return [] unless $xml->{resultset_web}->{result}; return $xml->{resultset_web}->{result}; } __DATA__ My 1st BOSS Search Demo

My 1st BOSS Search Demo


ソース / Yahoo! Search BOSS - YDN