Monitors a product's price on Amazon and adds to cart as soon as price drops below threshhold.
Monitors a product's price on Amazon and adds to cart as soon as price drops below threshhold.
Written in PhantomJS with CasperJS framework.
If you're on a Mac, it's quite simple using Homebrew.
brew install phantomjs
brew install casperjs
You may also download and install each from the websites above.
There are fields at the top of the script you will need to modify.
casperjs --cookies-file=cookies.txt --disk-cache=yes casper-scrape.js
In the above command, cookies.txt
can be any filename you want. It's
the plain-text file PhantomJS will use to store the cookie info from
signing in. When you run the script after the first time that file has
been created from the script, you will already be signed in. To sign
out, just delete the cookie file.
When running the script the first time, you should see output like this:
Loading homepage
Checking signed-in status
Going to signin
Signing in
Signed in successfully
Loading product page (try #1 - Wed Nov 28 2012 20:08:12 GMT-0500 (EST))
Checking price
Current price: $999.99 (999.99)
Under threshhold of 800? false
Loading product page (try #2 - Wed Nov 28 2012 20:08:18 GMT-0500 (EST))
Checking price
Current price: $999.99 (999.99)
Under threshhold of 800? false
This will continue until the price of the product falls below the
priceThreshhold
. Once this happens, you'll see this:
Checking price
Current price: $688.00 (688.00)
Under threshhold of 800? true
Success! All systems GO!
Adding to cart
Selecting no protection coverage
Clicking edit-cart or proceed-to-checkout
Cart page
Done
In addition to all the output to your terminal above, a new directory called "images" has also been created storing the screen-captures of each of the steps run by the script. These help to debug if, for example, signing in isn't working.
Now you should be able to open your browser, sign in, and the product will be in your cart waiting for you to checkout. You will need to actually navigate to your cart to see it, as sometimes the cart item counter in the top right doesn't update until you load the cart page. But don't worry, it's there.