O'Reilly logo

Amazon Hacks by Paul Bausch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Send an Email Alert if a Review Is Added to a Product

This script keeps an eye on Amazon and notifies you when a new review is posted.

There are obviously some products you care about more than others, and it’s good to be aware of how those products are perceived. Reviews give feedback to publishers, authors, and manufacturers, help customers make buying decisions, and help other retailers decide what to stock. If you want to monitor all the reviews for a product or set of products, visiting each product detail page to see if a new review has been added is a tedious task.

Instead, you can use a script to periodically check the number of reviews for a given item, and have it send you an email when a new review is added.

The Code

You’ll need two nonstandard Perl modules to run this code: LWP::Simple to make the AWS (Amazon Web Services) request, and XML::Simple to parse the results. The combination provides a simple way to access AWS XML over HTTP with Perl [Hack #80]. Create a file called review_monitor.pl with the following code:

#!/usr/bin/perl
# review_monitor.pl
#
# Monitors products, sending email when a new review is added
# Usage: perl review_monitor.pl <asin>
use warnings;
use strict;
use LWP::Simple;
use XML::Simple;

# Your Amazon developer's token. 
my $dev_token='insert developer token';

# Your Amazon affiliate code. 
my $af_code='insert affiliate code';

# Location of sendmail and your email.
my $sendmailpath = 'insert sendmail path';
my $emailAddress = 'insert email address' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required