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' ...

Get Amazon Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.