added script for rudimentary shop stock checks
This commit is contained in:
parent
128804e311
commit
8a778d9e90
1 changed files with 25 additions and 0 deletions
25
check_shop_stock.sh
Executable file
25
check_shop_stock.sh
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Checks when the Bat Bone is in stock again
|
||||
|
||||
useragent1="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500 .45 Safari/537.36"
|
||||
useragent2="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0"
|
||||
url="http://shop.flitetest.com/multirotors/bat-bone-tri-370-kit/"
|
||||
error="Product is out of stock</div>"
|
||||
recipient="oli@lugh.ch"
|
||||
|
||||
# Shuffle User Agent
|
||||
rnd_ua=$(shuf -i 1-2 -n 1)
|
||||
|
||||
if [ $rnd_ua = 2 ]; then
|
||||
ua=$useragent2
|
||||
else
|
||||
ua=$useragent1
|
||||
fi
|
||||
|
||||
curl_cmd=$($(which curl) -s -A "$ua" $url | grep -c "$error")
|
||||
|
||||
if [ $curl_cmd -lt 1 ]; then
|
||||
echo -e "$(date)\n$url is available again!" | mail -s "In stock again ($url)" $recipient
|
||||
fi
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue