Skip to content

Instantly share code, notes, and snippets.

@jbn
Created September 15, 2021 21:14
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 jbn/74f1814dc7974302392564ee75196385 to your computer and use it in GitHub Desktop.
Save jbn/74f1814dc7974302392564ee75196385 to your computer and use it in GitHub Desktop.
import subprocess
import requests
from pyquery import PyQuery
import time
def send_to_pushover():
requests.post("https://api.pushover.net/1/messages.json", data={
"token": "XXX",
"user": "XXX",
"message": "GO GO GO"
})
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0'
}
for i in range(10000):
try:
print(f"Attempt {i}")
url = "https://www.bestbuy.com/site/playstation-5/ps5-consoles/pcmcat1587395025973.c?id=pcmcat1587395025973"
doc = PyQuery(requests.get(url, headers=headers).content)
for item in doc(".list-item.lv"):
sku = item.attrib.get('data-sku-id')
if sku not in {'6426149', '6430161'}:
continue
btn = PyQuery(item)('button').text().upper()
if 'SOLD OUT' not in btn:
send_to_pushover()
while True:
subprocess.call(["espeak", "it is available"])
time.sleep(60*5)
time.sleep(60*5)
except Exception as e:
print(e)
time.sleep(60*5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment