#!/usr/bin/perl use strict; use URI::Escape qw(uri_escape); use XML::Simple; use Unicode::String qw(latin1 utf8); use LWP::UserAgent; use HTTP::Request; my $yahooUrl = 'http://api.search.yahoo.com/ContentAnalysisService/V1/termExtraction'; my $appid = 'your_yahoo_appid'; my $string = 'Some sort of text to use with Yahoo!\'s content analysis web service'; my $ua = LWP::UserAgent->new(); $ua->agent("tagger v0.1)"); $ua->timeout(10); # the API requires utf8 url_encoded arguments my $req = HTTP::Request->new(GET=>"$yahooUrl?appid=$appid&context=".uri_escape(latin1($string)->utf8)); my $response = $ua->request($req); exit unless $response->is_success(); my $xml = XMLin($response->content(), ForceArray => ['Result']); foreach (@{$xml->{'Result'}}) { my $tag = utf8($_)->latin1; ## do something with each $tag ## } # Author: # Carlos Jorge Andrade # Reference: http://blog.karlus.net/archives/2005/05/17/1040/