Created
April 13, 2024 02:19
-
-
Save deversmann/809298c1d2155255528d96e40e8d2ac9 to your computer and use it in GitHub Desktop.
Basic script to set up as a cron job to check Microcenter stock of items regularly and put up macOS alerts when item is in stock.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
itemDescriptions=( | |
"Raspberry Pi 4B 8GB" | |
"Raspberry Pi 4B 2GB" | |
"Raspberry Pi 4B 4GB" | |
"Raspberry Pi 400" | |
) | |
itemURLs=( | |
"https://www.microcenter.com/product/622539/raspberry-pi-4-model-b-8gb-ddr4" | |
"https://www.microcenter.com/product/621439/raspberry-pi-4-model-b-2gb-ddr4" | |
"https://www.microcenter.com/product/637834/raspberry-pi-4-model-b-4gb-ddr4" | |
"https://www.microcenter.com/product/633751/raspberry-pi-400-includes-raspbery-pi-400-with-4gb-ram,-micro-sd-card-slot,-2-usb-30-ports,-1-usb-20-port,-usb-c-power-required" | |
) | |
storeNames=( | |
"Chicago" | |
"Westmont" | |
) | |
storeIDs=( | |
"151" | |
"025" | |
) | |
alertMsg=" is in stock at the Micro Center in " | |
for j in ${!storeIDs[@]}; do | |
for i in ${!itemURLs[@]}; do | |
curl -s -b "storeSelected=${storeIDs[$j]}" ${itemURLs[$i]} | grep -i "'inStock'" | grep -iq "True" | |
if [ $? -eq 0 ]; then | |
osascript -e "display notification \"${itemDescriptions[$i]} $alertMsg ${storeNames[$j]}\" with title \"Micro Center In Stock Alert\" sound name \"Hero\"" | |
fi | |
done | |
done | |
# */15 10-21 * * * |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment