2007年09月12日(水) 10:51

[を] Net::Amazon のメモ/MSM

#!/usr/bin/perl
use strict;
use warnings;
use Net::Amazon;
use Cache::File;
use Encode;
binmode STDOUT, ":utf8";

my $cache = Cache::File->new(cache_root => '/var/tmp/cache-amazon',
                             lock_level => Cache::File::LOCK_LOCAL(),
                             default_expires => '24 hours');

my $ua = Net::Amazon->new(token => 'YOUR_TOKEN',
                          locale => 'jp',
                          cache => $cache,
                          max_pages => 1,
                          );

#my $response = $ua->search(asin => '4873110505');
#my $response = $ua->search(blended => "Perl");
my $response = $ua->search(keyword => "Perl", mode => "books-jp");
#my $response = $ua->search(keyword => "Perl", mode => "books");

if (not $response->is_success()) {
    print "Error: ", $response->message(), "\n";
    exit;
}

print $response->as_string(), "\n";

for ($response->properties()) {
    print "Asin()\t", $_->Asin(), "\n";
    print "ProductName()\t", $_->ProductName(), "\n";
  %2
Amazon API をごにょごにょできるPerlモジュール。
エントリーナビ