keyboardcrunch

ParcelPendingPush.py

May 3rd, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.49 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. from selenium import webdriver
  4. from selenium.webdriver.common.by import By
  5. from selenium.webdriver.support.ui import WebDriverWait
  6. from selenium.webdriver.firefox.options import Options
  7. import pushover
  8.  
  9. site_login = "https://my.parcelpending.com/login"
  10. parcels = "https://my.parcelpending.com/parcel-history?package_status=1001"
  11. username = ""
  12. password = ""
  13.  
  14. options = Options()
  15. options.headless = True
  16. driver = webdriver.Firefox(options=options)
  17. driver.implicitly_wait(10)
  18.  
  19. def Notify(package):
  20.     ps = pushover.PushoverClient("./push")
  21.     try:
  22.         ps.send_message(package, title="Parcel Pending")
  23.     except:
  24.         print(package)
  25.  
  26. def Login():
  27.     driver.get(site_login)
  28.     driver.find_element_by_name("username").send_keys(username)
  29.     driver.find_element_by_name("password").send_keys(password)
  30.     driver.find_element_by_tag_name("button").click()
  31.  
  32. def GetParcels():
  33.     driver.get(parcels)
  34.     package_panel = driver.find_element_by_xpath("//section[@class='panel'][2]")
  35.     if package_panel.text == "There are no packages that match the specified criteria.":
  36.         print("No packages")
  37.     else:
  38.         table = driver.find_element_by_xpath("/html/body/section/div/section/section/section[2]/div/div[1]/table/tbody")
  39.         rows = table.find_elements(By.TAG_NAME, "tr")
  40.         for row in rows:
  41.             col = row.find_elements(By.TAG_NAME, "td")
  42.             parcel = col[2]
  43.             Notify(parcel.text)
  44.  
  45. Login()
  46. GetParcels()
  47. driver.quit()
Advertisement
Add Comment
Please, Sign In to add comment