【原创】Python 网易易盾滑块验证

网友投稿 366 2022-09-04


【原创】Python 网易易盾滑块验证

本文仅供学习交流使用,如侵立删!

记一次 网易易盾滑块验证分析并通过

操作环境

win10 、 mac Python3.9 selenium、PIL、numpy、scipy、matplotlib

分析

话不多少,借助之前写阿里云盾滑块和极验滑块的经验,直接上代码,详细可参考:[阿里云盾滑块验证]极验滑块验证(get_images(self): """ 获取验证码图片 :return: 图片的location信息 """ url = selenium_item.get_attribute("src") if url is not None: response = requests.get(url) with open(path, "wb") as f: f.write(response.content) img = Image.open(path).resize(size) img.save(path) else: class_name = selenium_item.get_attribute("class") js_cmd = ( 'return document.getElementsByClassName("%s")[0].toDataURL("image/png");' % class_name ) im_info = self.driver.execute_script(js_cmd) im_base64 = im_info.split(",")[1] im_bytes = base64.b64decode(im_base64) with open(path, "wb") as f: f.write(im_bytes) img = Image.open(path).resize(size) img.save(path) def compute_gap(self, array): """ 计算缺口偏移 """ grad = np.array(array > 0) h, w = grad.shape # img_show(grad) rows_sum = np.sum(grad, axis=1) cols_sum = np.sum(grad, axis=0) left, top, bottom = 0, 0, h # get the top index p = np.max(rows_sum) * 0.5 for i in range(h): if rows_sum[i] > p: top = i break for i in range(h - 1, -1, -1): if rows_sum[i] > p: bottom = i break p = np.max(cols_sum) * 0.5 for i in range(w): if cols_sum[i] > p: left = i break return top, bottom + 1, left

生成滑动轨迹

def get_tracks(distance): v = random.randint(0, 2) t = 1 tracks = [] cur = 0 mid = distance * 0.8 while cur < distance: if cur < mid: a = random.randint(2, 4) else: a = -random.randint(3, 5) s = v * t + 0.5 * a * t ** 2 cur += s v = v + a * t tracks.append(round(s)) tracks.append(distance - sum(tracks)) return tracks

滑动模块

效果

资源下载

本文仅供学习交流使用,如侵立删!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Mybatis实现分包定义数据库的原理与过程
下一篇:Python自动化办公--Pandas玩转Excel【一】python处理Excel实现自动化办公教学(含实战)【一】python处理Excel实现自动化办公教学(含实战)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~