Friday, January 19, 2007

PowerShell and Amazon Web Services (AWS) - part 1

I have a large collection of books gathering dust.  I need to try to sell them.  I had started down trying to automate a process to list my books last year, but never finished.  I began with Perl examples from O'Reilly's Amazon Hacks.

That was then, this is now.  I want to automate this with PowerShell!

blog entry by amida168 has helped me to get started, and is the basis of my first part in a series of entries where I try to expore AWS using PowerShell.

First this is to sign up for a free AWS account free AWS account.

With my first PowerShell script, using amida168's example, I'm simply going to get a price for a book that I know the ISBN for.

aws_lookup.ps1 (I may need to work on the formatting):


$url = ""
$url += "&AWSAccessKeyId=enter_your_aws_key_here"
$url += "&Operation=ItemLookup"
$url += "&ItemId=$asin"
$url += "&ResponseGroup=Offers"

$rxml = [xml](new-object Net.WebClient).DownloadString("$url")
$price = $rxml.ItemLookupResponse.Items.Item.Offers.Offer.OfferListing.Price.Amount
$price = $price/100
write-host $price

[end aws_lookup.ps1]

So, you simply call it as .\aws_lookup.ps1 some_ISBN.

For example, I'm going to lookup the price for Microsoft Windows PowerShell Programing for the Absolute Beginner:

PSH> .\lookup.ps1 1598633546

There, I've got the current selling price of the book.

From here on, I need to determine how to get the pricing for used books, whether this all works the same for, how to get the data from Excel, how to automate the listing of books I have, etc.  Stay tuned!