I used a PowerShell script to check price of Garmin i3 on Amazon. It’s very easy to modify it to check the availability of PS3. When the PS3 is not available, the price from the query is $0.00. So, if the price is greater than 0 that means it’s available. The script then prepares an email with a link to purchase it.
You need to change the SMTP server name ($smtpserver), your email address ($email) and AWSAccessKeyId ($awskey). If you don’t know how to get an AWSAccessKeyId, you can check out my original post for the Garmin i3. The default is to check the model with 60GB HD. Uncomment the second $asin to check the model with 20GB HD.
Once you test the script with your changes, use your favorite scheduler to check availability routinely.
# Script for checking PS3 on Amazon
$smtpserver = "smtp.nospam.com"
$email = "someone@nospam.com"
$awskey = "YOUR-AWSAccessKeyId"
$asin = "B0009VXAM0" #60GB
#$asin = "B000IZWNLG" #20GB
$url = "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService"
$url += "&AWSAccessKeyId=" + $awskey
$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
if ($price -gt 0) {
$textbody = "Playstation 3 is now $" + $price + " at Amazon "
$textbody += "http://www.amazon.com/exec/obidos/ASIN/" + $asin + "/animereviews-20/ref=nosim"
$smtp = new-object Net.Mail.SmtpClient($smtpserver)
$smtp.send($email, $email , "PS3 Available at Amazon!", $textbody)
}
I got some experiences with Amazon Web Service when I created my Anime Reviews site. It’s pretty neat that you can write a query to look up very detailed product information. Recently, I am thinking to buy a Garmin StreetPilot i3 from Amazon.

The regular price is around $308.00, but I heard that sometimes Amazon would lower the price to as low as $199.00. However, the low price is only available for a short time. I don’t want to sit in front of my computer and manually check the price myself. Wouldn’t it be nice if I can have a script to check the price automatically? It would be nicer if I write the script using PowerShell!
Ok, enough rambling. Let’s get started. To use Amazon Web Service, the first thing to do is to create an account and obtain your own Access Key ID. You can create a free account here.
After the account has been created successfully, you can log on to the site with your new account. Move the mouse cursor on top of the button that says “Your Web Services Account”. A drop down menu would appear, click “View Access Key Identifiers”. There are two keys, one is called “Access Key ID”, the other is called “Secret Access Key”. Make a note of the Access Key ID, this is the key you used for the web service. The next step is sending the Secret Access Key to me.
Ok, just kidding. You should NOT share Secret Access Key with anyone, it’s only used to create signature. You should keep it confidential and not reveal it to anyone.
Amazon Web Service offers several ways to find product information. ItemSearch is used to search products by using keywords. Since we already know the product that we are interested in, we can just use ItemLookup. To use ItemLookup, you need two pieces of information, AWSAccessKeyId and ItemId. You already have the Access Key ID, all you need to know is the ItemId for the product. Each product offered on Amazon has a unique ID. If you look at a product page, it’s called ASIN. You use ASIN as ItemId for the query. For books query, use ISBN as ItemId in your query. This is the query string for looking up information for the Garmin i3.
$url = "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService"
$url += "&AWSAccessKeyId=Your_AccessKeyID_Here"
$url += "&Operation=ItemLookup"
$url += "&ItemId=B000ACHVVE"
$url += "&ResponseGroup=Offers"
Note that this is for North America www.amazon.com. If you want to query product information for other Amazon sites. You need to change the first line accordingly. You can check here for information on how to modify the query string. Another point to note is that if you don’t specify ResponseGroup in your query, the default response is “Request” and “Small” which don’t have the price information. To get the current price, we use “Offers” as response group. Finally, we use .Net’s Net.WebClient class to get the response from Amazon Web Service. The response from the server is an xml string. We can cast it to XMLDocument for easy accessing the data. The amount returned from the query is in cents, so divide it by 100 to get the dollar amount.
$rxml = [xml](new-object Net.WebClient).DownloadString("$url")
$price = $rxml.ItemLookupResponse.Items.Item.Offers.Offer.OfferListing.Price.Amount
$price = $price/100
echo $price
You might ask how did you come up with the offer price? You can check the documentation in Amazon Web Service web site, or you can save the response as an XML file and use your favorite XML editor/reader to examine the response. FireFox is just fine to parse the XML file.
$sxml = (new-object Net.WebClient).DownloadString("$url")
echo $sxml > "c:\\response.xml"
I tested the script under Vista Beta 2 and it works well.
I haven't played with Monad shell for a while, the next thing I know there is a new scripting language called "Microsoft PowerShell". At first, I thought it's a brand new language, but actually they renamed Monad and made it PowerShell.
After installation, I tried to run one of my earlier Monad scripts. Just like the previous updates of Monad, the default execution policy is "Restricted". Under this policy, you can use PowerShell interactively. No scripts are allowed. If you like to run your own scripts without signing, you need to change the execution policy. Now there is a cmdlet to change policy without using regedit. Here is the cmdlet to change the policy to RemoteSigned.
Set-ExecutionPolicy RemoteSigned