python selenium破解极验3滑动验证码

一、采用物理加速度公式算法

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
def get_track(self, distance):
"""
获取滑块移动轨迹的列表
:param distance: 第二个缺块的左侧的x坐标
:return: 滑块移动轨迹列表
"""
track = []
current = 2
mid = distance * 1 / 2
mid0 = distance * 1 / 4
mid1 = distance * 1 / 8
t = 0.2
v = 50
distance += 10 # 使滑块划过目标地点, 然后回退
while current < (distance - 10):
if current < mid1:
a = random.randint(4, 10)
elif current < mid0:
a = -random.randint(6, 8)
elif current < mid:
a = random.randint(4, 10)
v0 = v
v = v0 + a * t
s = v0 * t + 0.5 * a * t * t
current += s
a = -random.randint(6, 7)
track.append(round(s))

for i in range(2):
track.append(-random.randint(2, 3))
for i in range(2):
track.append(-random.randint(1, 4))

return track

注意此方法已经不可用,会被识别出来,结果会显示图片被怪物吃掉了。

二、采用轨迹离散分布生成的算法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 轨迹公式,也可采用其他公式
def ease_out_quart(self, x):
return 1 - pow(1 - x, 4)

def get_tracks_2(self, distance, seconds, ease_func):
"""
根据轨迹离散分布生成的数学 生成
成功率很高 90% 往上
:param distance: 缺口位置
:param seconds: 时间
:param ease_func: 生成函数
:return: 轨迹数组
"""
distance += 20
tracks = [0]
offsets = [0]
for t in np.arange(0.0, seconds, 0.1):
ease = ease_func
offset = round(ease(t / seconds) * distance)
tracks.append(offset - offsets[-1])
offsets.append(offset)
tracks.extend([-3, -2, -3, -2, -2, -2, -2, -1, -0, -1, -1, -1, -1, -2, -1]) #可以自己按情况改
return tracks

这种方法成功率很高,成功率在90%以上,破解极验3滑动验证码没什么问题。