-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtwtb.py
63 lines (48 loc) · 1.62 KB
/
twtb.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
#方便延时加载
import time
from selenium import webdriver
import numpy as np
import random
# 模拟浏览器打开网站
driver = webdriver.Chrome()
driver.get('https://web-vpn.sues.edu.cn')
# 将窗口最大化
driver.maximize_window()
#browser.find_element_by_xpath('/html/body/div[1]/div/div[4]/span/a[1]').click()
# 延时2秒,以便网页加载所有元素,避免之后找不到对应的元素
time.sleep(2)
#//*[@id="username"]
#/html/body/div[2]/div[1]/div[2]/div/div[1]/div/div/form[1]/div[2]/input
# acc and pwd (自己写)
accounts = ''
pwd = ''
# Find UserName and pwd, login
driver.find_element_by_xpath(
"//*[@id='username']").send_keys(accounts)
driver.find_element_by_xpath(
"//*[@id='password']").send_keys(pwd)
# 在输入用户名和密码之后,点击登陆按钮
driver.find_element_by_xpath("//*[@id='passbutton']").click()
time.sleep(2)
# 点击健康填报信息
# 需在最近访问中置顶
driver.find_element_by_xpath("//*[@id='group-4']/div[2]/div/div[2]/p[1]").click()
time.sleep(5)
handles = driver.window_handles
#获取当前页句柄
print(handles)
driver.switch_to.window(handles[1])
# randomly choose a temperature
a = random.uniform(35,37)
temprature = round(a,1)
print(temprature)
driver.find_element_by_xpath("//*[@id='form']/div[18]/div[1]/div/div[2]/div/div/input").send_keys(str(temprature))
#time.sleep(2)
#//*[@id="form"]/div[18]/div[1]/div/div[2]/div/div/input
driver.find_element_by_xpath('//*[@id="post"]').click()
#time.sleep(10)
# proceed
print("体温填报成功")
time.sleep(5)
# quit browser
driver.quit()