抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

Google验证码_打码

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
import time
import requests
from datetime import datetime
from selenium import webdriver


def valid_date(timestr):
nowTime_str = datetime.now().strftime('%Y-%m-%d')
# mktime参数为struc_time,将日期转化为秒,
e_time = time.mktime(time.strptime(nowTime_str, "%Y-%m-%d"))
# print(e_time)
try:
s_time = time.mktime(time.strptime(timestr, '%Y-%m-%d'))
# print(s_time)
# 日期转化为int比较
diff = int(s_time) - int(e_time)
# print(diff)
if diff >= 0:
is_true = True
# print('True')
return is_true
else:
is_true = False
# self.show_data.emit('测试版本已不能试用!!!')
# print('测试版本已不能试用!!!')
print('False')
return is_true
except Exception as e:
print(e)
return 0


class SeleniumTest(object):
"""用来测试selenium相关脚本"""

def __init__(self):
self.url = "https://www.ispfsb.com/Public/FOID.aspx"
self.__options = webdriver.ChromeOptions()
self.__options.binary_location = "C:\Program Files\Google\Chrome\Application\chrome.exe"
self.driver = webdriver.Chrome(options=self.__options)
self.driver.maximize_window()

@staticmethod
def verify(response):
url = "https://www.ispfsb.com/Reg/signup.aspx"
data = {"g-recaptcha-response": response}
response = requests.post(url, data=data)
if response.status_code == 200:
return response.text

@staticmethod
def create_task():
url = 'http://api.recaptcha.press/task/create?siteKey=6LdAHv8UAAAAAC-KuK02qHMG7nLPZ3WpxZs7eG6K&siteReferer=https://www.ispfsb.com/&authorization=0a389ac1-ab1a-4d60-a089-1f182bd12461'

try:
response = requests.get(url)
if response.status_code == 200:
data = response.json()
print('response data:', data)
return data.get('data', {}).get('taskId')
except requests.RequestException as e:
print('create task failed', e)

@staticmethod
def polling_task(task_id):
url2 = 'https://api.recaptcha.press/task/status?taskId=%s' % task_id
count = 0
while count < 60:
try:
response = requests.get(url2)
if response.status_code == 200:
data = response.json()
print('polling result', data)
status = data.get('data', {}).get('status')
print('status of task', status)
if status == 'Success':
return data.get('data', {}).get('response')
except requests.RequestException as e:
print('polling task failed', e)
finally:
count += 1
time.sleep(3)

def get_data(self):
"""请求页面"""
self.driver.get(self.url)
time.sleep(3)
self.driver.execute_script(
"""document.querySelector("#divStep1 > div:nth-child(2) > div > span > a").click();""")
# time.sleep(3)
input("信息填完后按回车:")
task_id = self.create_task()
task_id = self.polling_task(task_id)
print("task_id:", task_id)
js_code = 'document.getElementById("g-recaptcha-response").innerHTML="{}";'.format(task_id)
print(js_code)
self.driver.execute_script(js_code)


if __name__ == "__main__":
is_true = valid_date("2021-09-10")
if is_true:
st = SeleniumTest()
while True:
st.get_data()

else:
print('测试到期!!!')

评论

测试阶段