Skip to content

Instantly share code, notes, and snippets.

@pbuckley4192
Created June 28, 2019 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbuckley4192/3a0a583f7cb71a4b000315962a26a32a to your computer and use it in GitHub Desktop.
Save pbuckley4192/3a0a583f7cb71a4b000315962a26a32a to your computer and use it in GitHub Desktop.
import requests
import json
import subprocess
r = requests.get('https://thepihut.com/products/raspberry-pi-4-model-b.js').json()
count = r["variants"][2]["inventory_quantity"]
available = r["variants"][2]["available"]
print("RPI Available:\t"+ str(count))
def sendmessage(message):
subprocess.Popen(['notify-send', message])
return
sendmessage("RPI Available:\t"+ str(count))
if count > 0 or available == True:
# Notify Discord
url = '<DISCORD WEBHOOK URL>'
payload = {'content': "RPI 4 Available, Num Units:\t" + str(count)}
headers = {'content-type': 'application/json'}
response = requests.post(url, data=json.dumps(payload), headers=headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment