#!/usr/local/bin/perl # -*- coding: utf-8 -*- use strict; use warnings; use Encode; use CGI; use LWP::Simple; use HTML::Template; use URI::Escape; use utf8; use XML::Simple; binmode STDOUT, ":utf8"; $| = 1; my $appid = "gUxspU.xg66pvU6W5OJMz0vH10FYB.FT4sWcQomZrtmPD6sG.14VlAuMdCGoBuIeMyOpRtlJBlc-"; # appid は自分で取得したものをご利用下さい。 # http://e.developer.yahoo.co.jp/webservices/register_application my $q = new CGI; my $template = join("", ); my $t = HTML::Template->new(scalarref => \$template, global_vars => 1, loop_context_vars => 1, die_on_bad_params => 0); my $query = $q->param('q') || ""; $query = Encode::decode_utf8($query) unless utf8::is_utf8($query); if ($query eq "") { print $q->header(-charset => "UTF-8"); print $t->output(); exit; } print $q->header(-charset => "UTF-8"); my $rvs_ref = get_results_auc({q => $query}); $t->param(list => $rvs_ref) if $rvs_ref; $t->param(query => $query); my $out = $t->output(); print $out; exit; sub get_results_auc { my ($args_ref) = @_; my $ecq = URI::Escape::uri_escape_utf8($args_ref->{q}); my $url = "http://auctions.yahooapis.jp/AuctionWebService/V2/search?" ."appid=$appid&query=$ecq"; my $response = get($url); my $xmlsimple = XML::Simple->new(); my $xml = $xmlsimple->XMLin($response, ForceArray => [ 'Item' ]); return [] unless $xml->{Result}->{Item}; my @hits; foreach my $e (@{$xml->{Result}->{Item}}) { push @hits, { name => Encode::decode_utf8($e->{Title}), url => $e->{AuctionItemUrl}, price => int($e->{CurrentPrice}), image => $e->{Image}->{content}, }; } return \@hits; } __DATA__ yaus<TMPL_IF name=query>: <TMPL_VAR name=query></TMPL_IF>
見つかりませんでした...

(Webサービス by Yahoo! JAPAN)