-
Notifications
You must be signed in to change notification settings - Fork 0
/
reportDaily.py
100 lines (92 loc) · 3.81 KB
/
reportDaily.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import requests
from selenium import webdriver
import time
import traceback
"""
使用的edge浏览器,需要对应的驱动
上报成功sever酱会发送消息,需要有自己的sckey
"""
driver = "D:\\software\\program1\\edgedriver_win64\\msedgedriver.exe"
ID = '' #学号
pwd = '' #密码
sckey = '' # sever酱sckey
try:
#edge驱动的位置
driver = webdriver.Edge(driver)
#cau疫情防控常态化管理系统 -- 每日上报
driver.get("https://wep.cau.edu.cn/cauncovxs/wap/default/index")
'''
调用selenium库中的find_element_by_xpath()方法定位搜索框,
同时使用send_keys()方法在其中输入信息
'''
#账号输入框
driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/input').send_keys(ID)
#密码输入框
driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/input').send_keys(pwd)
'''
调用selenium库中的find_element_by_xpath()方法定位搜索按钮,
同时使用click()方法对按钮进行点击
'''
#点击登录
driver.find_element_by_xpath('//*[@id="app"]/div[3]').click()
driver.implicitly_wait(5)
time.sleep(5)
#获取位置信息
"""
js="document.getElementById('').scrollTop=100000"
driver.execute_script(js)
"""
element = driver.find_element_by_xpath("/html/body/div[1]/div/div/section/div[4]/ul/li[9]/div")
driver.execute_script("arguments[0].click();", element)
driver.implicitly_wait(10)
time.sleep(5)
#7日内是否有共同居住者返京
element = driver.find_element_by_xpath("/html/body/div[1]/div/div/section/div[4]/ul/li[10]/div/div/div[2]")
driver.execute_script("arguments[0].click();", element)
driver.implicitly_wait(10)
time.sleep(5)
#今日体温范围
element = driver.find_element_by_xpath("/html/body/div[1]/div/div/section/div[4]/ul/li[11]/div/div/div[2]")
driver.execute_script("arguments[0].click();", element)
driver.implicitly_wait(10)
time.sleep(5)
#是否已接种疫苗
element = driver.find_element_by_xpath("/html/body/div[1]/div/div/section/div[4]/ul/li[12]/div/div/div[1]")
driver.execute_script("arguments[0].click();", element)
driver.implicitly_wait(5)
time.sleep(5)
#疫苗接种地
element = driver.find_element_by_xpath("/html/body/div[1]/div/div/section/div[4]/ul/li[13]/div/div/div[1]")
driver.execute_script("arguments[0].click();", element)
driver.implicitly_wait(5)
time.sleep(5)
#加强针
element = driver.find_element_by_xpath("/html/body/div[1]/div/div/section/div[4]/ul/li[14]/div/div/div[1]")
driver.execute_script("arguments[0].click();", element)
driver.implicitly_wait(5)
time.sleep(5)
#今日同住人员
element = driver.find_element_by_xpath("/html/body/div[1]/div/div/section/div[4]/ul/li[25]/div/div/div[2]")
driver.execute_script("arguments[0].click();", element)
driver.implicitly_wait(5)
time.sleep(5)
#昨日是否核酸,点“是“
element = driver.find_element_by_xpath("/html/body/div[1]/div/div/section/div[4]/ul/li[27]/div/div/div[1]")
driver.execute_script("arguments[0].click();", element)
driver.implicitly_wait(5)
time.sleep(5)
#点击提交
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div/section/div[5]/div").click()
driver.implicitly_wait(5)
time.sleep(5)
#点击确认
element = driver.find_element_by_xpath('//*[@id="wapcf"]/div/div[2]/div[2]')
driver.execute_script("arguments[0].click();", element)
url = 'https://sctapi.ftqq.com/%s.send?text=上报成功啦~&desp=In carnage, I bloom like a flower in the dawn'%sckey
requests.get(url)
except:
print(traceback.format_exc())
url = 'https://sctapi.ftqq.com/%s.send?text=上报失败咯……&desp=手动上报吧=='%sckey
requests.get(url)
finally:
driver.close()