#!/usr/bin/perl
###########################################
# asin_fetch
# Mike Schilli, 2003 (m@perlmeister.com)
# Fetch book info by ASIN
# asin_fetch 0201360683
###########################################
use warnings;
use strict;
use Net::Amazon;
use Net::Amazon::Request::ASIN;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init({level => $INFO, layout => '%F{1}-%L: %m%n'});
my $ua = Net::Amazon->new(
token => 'YOUR_AMZN_TOKEN',
);
die "usage: $0 asin\n(use 0201360683 as " .
"an example)\n" unless defined $ARGV[0];
my $req = Net::Amazon::Request::ASIN->new(
asin => $ARGV[0],
offer => 'All',
);
# Response is Net::Amazon::ASIN::Response
my $resp = $ua->request($req);
if($resp->is_success()) {
print $resp->as_string(), "\n";
my($p) = $resp->properties();
for(qw(CollectiblePrice CollectibleCount NumberOfOfferings
UsedCount ThirdPartyNewPrice ThirdPartyNewCount)) {
print "$_: ", $p->$_(), "\n";
}
} else {
print "Error: ",
$resp->message(), "\n";
}