Mugsy DeepDive Bot
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
# Requires: requests, bs4, python-pushover | |
import time | |
import requests | |
from bs4 import BeautifulSoup | |
from pushover import init, Client | |
known_last_updated = "" | |
USER_KEY = "<pushover_user_key>" | |
APP_KEY = "<pushover_app_key>" | |
EMAIL = "<your_email>" | |
BACKER_NUMBER = "<your_backer_number" | |
init(APP_KEY) | |
while True: | |
print("Checking deep dive") | |
result = requests.post("https://cloud.heymugsy.com/shipper/deepDiveResult.php", | |
data={"email": EMAIL, "backerNumber": BACKER_NUMBER}) | |
soup = BeautifulSoup(result.text, 'html.parser') | |
status = soup.select("body > div > div:nth-child(3) > div > p:nth-child(4) > b")[0].text.rstrip(" ") | |
expected_delivery = soup.select("body > div > div:nth-child(3) > div > p:nth-child(5) > b")[0].text | |
tracking = soup.select("body > div > div:nth-child(3) > div > p:nth-child(6) > b")[0].text | |
last_updated = soup.select("body > div > div:nth-child(3) > div > p:nth-child(7) > b")[0].text | |
print("Status '%s', delivery on %s, tracking #: '%s' and last updated %s" | |
% (status, expected_delivery, tracking, last_updated)) | |
if last_updated != known_last_updated: | |
print("Sending Notification") | |
Client(USER_KEY).send_message("Status '%s', delivery on %s, tracking #: '%s' and last updated %s" | |
% (status, expected_delivery, tracking, last_updated), title="Mugsy Update!") | |
known_last_updated = last_updated | |
time.sleep(60*60*2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment