-
Notifications
You must be signed in to change notification settings - Fork 0
/
daka.py
146 lines (119 loc) · 3.67 KB
/
daka.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import sys
import io
from selenium import webdriver
import time
import json
import requests
import base64
# usragent:Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Mobile Safari/537.36
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8') # 改变标准输出的默认编码
# 建立chrome浏览器对象,括号里是Chromedriver在你的电脑上的路径,需要修改
browser = webdriver.Chrome('/Users/rockontrol/Desktop/daka/chromedriver')
# 基本信息,需要修改
xuehao = 'xxxx'
name = 'xxxx'
password = 'xxxx'
# 登录页面
url = 'https://wxyqfk.zhxy.net/?yxdm=14262#/login'
browser.set_window_size(598, 702)
# 访问登录页面
browser.get(url)
# 等待一定时间,让js脚本加载完毕
browser.implicitly_wait(5)
time.sleep(3)
# print(browser.page_source.encode('utf-8').decode())
# 定位输入框并输入相关信息
browser.find_elements_by_class_name("van-field__control")[0].send_keys(xuehao)
browser.find_elements_by_class_name("van-field__control")[1].send_keys(name)
browser.find_elements_by_class_name("van-field__control")[3].send_keys(password)
# 等待一定时间,让js脚本加载完毕
browser.implicitly_wait(3)
time.sleep(2)
# browser.sleep(3)
browser.find_element_by_xpath('//button').click()
browser.implicitly_wait(3)
time.sleep(2)
# 地址重定向到登陆后页面
url2 = 'https://wxyqfk.zhxy.net/?yxdm=14262#/clockIn'
browser.set_window_size(598, 702)
browser.get(url2)
browser.implicitly_wait(10)
try:
but = browser.find_element_by_class_name("van-button")
but.click()
except:
browser.get(url2)
# browser.get(url2)
# but = browser.find_element_by_class_name("van-button")
# but.click()
time.sleep(2)
try:
wenxintishi=browser.find_element_by_class_name('van-button')
# print('find')
wenxintishi.click()
except:
time.sleep(2)
print('not find')
# browser.get(url2)
try:
browser.find_element_by_class_name('sign-in-btn')
print('跳转成功')
browser.find_element_by_class_name('sign-in-btn')
except:
print('跳转失败,重新跳转')
browser.get(url2)
time.sleep(3)
browser.find_element_by_class_name('sign-in-btn')
browser.find_element_by_class_name('van-button').click()
# 关闭有个温馨提示的框
try:
wenxintishi=browser.find_element_by_class_name('van-button')
print('find')
wenxintishi.click()
except:
time.sleep(2)
print('not find')
# browser.get(url2)
time.sleep(3)
try:
browser.find_element_by_class_name('sign-in-btn').click()
except:
wenxintishi=browser.find_element_by_class_name('van-button')
# print('find')
wenxintishi.click()
browser.find_element_by_class_name('sign-in-btn').click()
time.sleep(3)
try:
browser.find_element_by_tag_name('img')
# browser.get(url2)
time.sleep(3)
browser.find_element_by_class_name('sign-in-btn').click()
try:
browser.find_element_by_class_name('sign-in-btn').click()
except:
pass
except:
pass
browser.find_elements_by_xpath('//label')[0].click()
browser.find_elements_by_xpath('//label')[6].click()
browser.find_elements_by_xpath('//label')[14].click()
time.sleep(2)
image = browser.find_element_by_tag_name('img').get_attribute('src')
# print(image.split(',')[1])
try :
browser.execute_script("window.scrollTo(0,document.body.scrollHeight)")
# print('gun')
except:
pass
print(image)
#验证码识别ocr
from recognize import recognize
from recognize import recognize2
data1 = recognize(image)
data2 = recognize2(image)
# print(data1)
from recognize import json1
k = json1(data1)
m = json1(data2)
# print(k)
browser.find_elements_by_class_name("van-field__control")[2].send_keys(k)