Preface
Python crawler to monitor rental status of gaming accounts
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| from selenium import webdriver import time import os from selenium.webdriver.common.by import By
before_start = True start = False driver = webdriver.Chrome() time.sleep(5) os.system("""osascript -e 'display notification "Renting gaming accounts monitoring has started" with title "" subtitle ""'""") while True: driver.get("https://www.zuhaowan.com/zuhao/13163494.html") time.sleep(2) try: dd = driver.find_element(by=By.ID, value="dd").text hh = driver.find_element(by=By.ID, value="hh").text mm = driver.find_element(by=By.ID, value="mm").text ss = driver.find_element(by=By.ID, value="ss").text start = True except Exception as result: start = False if start: if before_start != start: os.system("""osascript -e 'display notification "Renting service has started" with title "" subtitle ""'""") before_start = start else: if before_start != start: os.system("""osascript -e 'display notification "Renting service has ended" with title "" subtitle ""'""") before_start = start
|
Done