I'm having a hell of a time catching an item in-stock on a web site. I keep missing it by about a half hour or so.
How can I pull the contents of the Nikon store page ( http://shop.nikonusa.com/store/nikonusa/en_US/pd/productID.249538300 ) and email an alert to myself (address@gmail.com) when the grey "where to buy" button has been replaced with the yellow "shop now" button ( which can be seen here: http://shop.nikonusa.com/store/nikonusa/en_US/pd/productID.226487200 ). Is this possible from a bash script, or is it too complex?
Thank you!
You could use curl to grab the web page then grep to search for the alt text of the button...
#!/bin/bash
#D800
x=$( curl -s http://shop.nikonusa.com/store/nikonusa/en_US/pd/productID.249538300 | grep 'alt="Buy Now"')
#D7000 (for testing)
#x=$( curl -s http://shop.nikonusa.com/store/nikonusa/en_US/pd/productID.226487200 | grep 'alt="Buy Now"')
if [ ! -n "$x" ]
then
echo Not Available
exit 1
fi
echo "Get clicking" | mail -s "D800 Available" you@example.com