【代码】Python爬虫租号玩监测出租状态

前言

Python爬虫租号玩监测出租状态

源代码

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 "租号玩监测已开启" 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 "租号服务已开始" with title "" subtitle ""'""")
before_start = start
else:
if before_start != start:
os.system("""osascript -e 'display notification "租号服务已结束" with title "" subtitle ""'""")
before_start = start

完成