Skip to content

Instantly share code, notes, and snippets.

@neilmenon
Created June 8, 2023 16:49
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 neilmenon/875d966ab559019fe45ee1adea4a087e to your computer and use it in GitHub Desktop.
Save neilmenon/875d966ab559019fe45ee1adea4a087e to your computer and use it in GitHub Desktop.
import requests
import datetime
def print_log(message: str):
print("[{}] ".format(str(datetime.datetime.now())) + message)
on_url = "https://oldnavy.gap.com/browse/product.do?pid=473484012&cid=72305&pcid=72305&vid=1&cpos=20&cexp=2223&kcid=CategoryIDs%3D72305&cvar=16849&ctype=Listing&cpid=res2212252059442943921053#pdp-page-content"
html = requests.get(on_url).text
if "M out of stock" in html:
print_log("Still not in stock...")
else:
print_log("Back in stock!")
api_token = "<API_TOKEN>"
url = "https://api.pushover.net/1/messages.json"
user_key = "<USER_KEY>"
body = {
'token': api_token,
'user': user_key,
'message': "XS Frost-Free Water-Resistant Zip-Front Puffer Vest for Men is back in stock",
'title': "Back in Stock!",
'url': url,
'url_title': "Open in Old Navy"
}
response = requests.post(url, data=body)
print_log("\tNotification sent with response: {}".format(response.text))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment