#!/usr/bin/perl -T use strict; use warnings; use Encode; use CGI qw/-no_xhtml/; use LWP::Simple; use XML::Simple; use URI::Escape; my $q = new CGI; my $key = $q->param('key') || ""; my $ekey = URI::Escape::uri_escape($key); print $q->header(-charset => 'UTF-8'), $q->start_html(-title => 'psearch', -lang => 'JP'), $q->h1('psearch (RSS)'), $q->start_form(-method => 'GET'), $q->textfield(-name => 'key', -size => 20), $q->submit(-value => 'search'), $q->end_form(), $q->h2('Search Results'); my $url = "http://psearch.yahoo.co.jp/rss?p=$ekey&ei=UTF-8&rss=1"; my $r = get_presults($url); foreach (@$r) { print encode('UTF-8', $q->h3($q->a({href => $_->{link}}, $_->{title})). $q->p($_->{description})), "\n"; } print $q->end_html(), "\n"; sub get_presults { my ($url) = @_; my $rss = get($url); my $xmlsimple = XML::Simple->new(ForceArray => [ 'item' ]); my $xml = $xmlsimple->XMLin($rss); return $xml->{channel}->{item}; }