|
@@ -85,7 +85,7 @@ class RotateIdent:
|
|
|
处理旋转验证码的核心方法
|
|
|
"""
|
|
|
try_count = 0
|
|
|
- while self.need_ident() and try_count < 5:
|
|
|
+ while self.need_ident() and try_count < 4:
|
|
|
try_count += 1
|
|
|
logging.info('开始处理旋转验证码,第 %s 次', try_count)
|
|
|
tag2 = self.page.query_selector('//div[@class="red-captcha-slider"]')
|
|
@@ -94,19 +94,17 @@ class RotateIdent:
|
|
|
if response['code'] != 200:
|
|
|
logging.error(response['msg'])
|
|
|
else:
|
|
|
- angle = int(str(response['data']['res_str']).replace('顺时针旋转', '').replace('度', ''))
|
|
|
+ angle = response['data']['angle']
|
|
|
# 使用鼠标操作进行点击并保持
|
|
|
bbox = tag2.bounding_box()
|
|
|
x_center = bbox['x'] + bbox['width'] / 2
|
|
|
y_center = bbox['y'] + bbox['height'] / 2
|
|
|
self.page.mouse.move(x_center, y_center)
|
|
|
self.page.mouse.down()
|
|
|
- # 等待一段时间
|
|
|
- time.sleep(1)
|
|
|
# 计算实际滑动距离 = 像素距离 + 前面空白距离
|
|
|
move_x = angle * 0.79
|
|
|
- # 滑动鼠标
|
|
|
- self.page.mouse.move(x_center + move_x, y_center + 5)
|
|
|
+ # 滑动滑块,且坐标多增加一个像素,添加误差
|
|
|
+ self.page.mouse.move(x_center + move_x + 1, y_center + 5, steps=10)
|
|
|
# 等待一段时间
|
|
|
time.sleep(1)
|
|
|
# 释放鼠标按钮
|