Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

inkdroid (3294)

inkdroid
  (email not shown publicly)
http://www.inkdroid.org/
AOL IM: inkdroid (Add Buddy, Send Message)
Yahoo! ID: summe_e (Add User, Send Message)
Jabber: inkdroid

inkdroid is a person, not a robot. however, inkdroid likes ink. inkdroid likes perl too.

Journal of inkdroid (3294)

Friday January 03, 2003
10:02 AM

Amazon Web Services

[ #9738 ]

Intruiged after I saw brian d foy's journal entry on Amazon's Web Services I registered for a developer token [free], and wrote a program to pull down my wishlist periodically for my personal website.

LWP::Simple and XML::Simple made this so simple I had to paste the code here

#!/usr/local/bin/perl

use strict;
use LWP::Simple;
use XML::Simple;

## fetch the wishlist from amazon

my $token = 'YOUR DEVELOPERS TOKEN HERE';
my $wishlistId = 'YOUR WISHLIST ID HERE';
my $host = 'xml.amazon.com';
my $path = 'onca/xml2';
my $query =
   "t=webservices-20" .
   "&dev-t=$token" .
   "&type=heavy" .
   "&f=xml" .
   "&WishlistSearch=$wishlistId";

my $wishlist = XMLin( get( "http://$host/$path?$query" ) );

## write out paltry HTML

foreach my $item (@{ $wishlist->{ Details } } ) {

   my $isbn = $item->{ Isbn };
   my $title = $item->{ ProductName };
   my $author = $item->{ Authors }{ Author };
   $author = $author->[0] if ( ref( $author ) eq 'ARRAY' );
   my $publisher = $item->{ Manufacturer };
   my $img = $item->{ ImageUrlSmall };
   $img = qq(<IMG SRC="$img" BORDER=0 ALIGN="left">) if $img;
   my $listPrice = $item->{ ListPrice };
   my $amazonPrice = $item->{ OurPrice };
   my $usedPrice = $item->{ UsedPrice } || 'n/a';
   my $url = $item->{ url };

   print

<<ITEM;
<A HREF="$url">$title</a> by $author
$img
<B>Publisher:</B> $publisher <BR>
<B>ISBN:</B> $isbn <BR>
<B>List:</B> $listPrice <BR>
<B>Amazon:</B> $amazonPrice <BR>
<B>Used:</B> $usedPrice <BR><BR>
ITEM

}

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.