CEX stock monitoring

It’s been ages since I posted anything, I’ve been playing with all sorts of stuff, like Cocos2D and SpriteKit… as well as wicked little things like this DIY Gamer kit. Maybe I’ll do some more long form ish posts soon about those. In the meantime though here’s a silly little bash script that I just put in cron:


#!/bin/bash

# for i in `wget -O - -o /dev/null https://uk.webuy.com/product.php?sku=5060327531071 | grep -oE "branchId=([[:digit:]]{1,3})" - | cut -d'=' -f2`; do if [ $i -eq 100 ] then; echo "Found" ; fi ; done

DECEPTION_VITA="https://uk.webuy.com/product.php?sku=5060327531071"
DECEPTION_PS3="https://uk.webuy.com/product.php?sku=5060327531002"

ST_ALBANS=100
WATFORD=19
HEMEL=56
STRATFORD=120

for store in `wget -O - -o /dev/null $DECEPTION_VITA | grep -oE "branchId=([[:digit:]]{1,3})" - | cut -d'=' -f2`; do
if [ $store -eq $ST_ALBANS ]
then
echo "Vita Deception in stock St. Albans"
fi
if [ $store -eq $WATFORD ]
then
echo "Vita Deception in stock Watford"
fi
if [ $store -eq $HEMEL ]
then
echo "Vita Deception in stock Hemel"
fi
# if [ $store -eq $STRATFORD ]
# then
# echo "Test confirmed, PS3 Deception in store Stratford."
# fi
done

for store in `wget -O - -o /dev/null $DECEPTION_PS3 | grep -oE "branchId=([[:digit:]]{1,3})" - | cut -d'=' -f2`; do
if [ $store -eq $ST_ALBANS ]
then
echo "PS3 Deception in stock St. Albans"
fi
if [ $store -eq $WATFORD ]
then
echo "PS3 Deception in stock Watford"
fi
if [ $store -eq $HEMEL ]
then
echo "PS3 Deception in stock Hemel"
fi
done

It takes urls for products and store id’s then via crons MAILTO environment variable it will email me if it finds those games in stock. It’s an experiment, and the code is a bit ‘dumb’. It should really loop around URLS and store IDs but for my purposes it’s fine.

This entry was posted in Games, Programming. Bookmark the permalink.