Created
September 15, 2021 21:14
-
-
Save jbn/74f1814dc7974302392564ee75196385 to your computer and use it in GitHub Desktop.
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
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