当前位置: 首页 > ds >正文

dp自动化登陆之hCaptcha 验证码

hCaptcha 是一种常见的验证码服务,用于区分人类用户和自动化程序。由于其基于图像识别和行为分析,下面介绍如何使用自动化点击验证码完成登陆。
思路:登陆目标网站触发验证码,截图并发给打码平台返回坐标,模拟人工点击完成验证

1、注册识别 hCaptcha API,获取授权

在这里插入图片描述

import requests
def get_rect(base64_list, title_list):url = "https://api.acedata.cloud/captcha/recognition/hcaptcha"headers = {"accept": "application/json","authorization": "授权码","content-type": "application/json"}payload = {"queries": base64_list,"question": ",".join(title_list)}response = requests.post(url, json=payload, headers=headers).json()return response

2、登陆目标网站,触发网站验证码

在这里插入图片描述

co = ChromiumOptions().headless(False).auto_port()
co.set_argument('--enable-translate')
page = ChromiumPage(co)
co.incognito()
page.get('https://www.ebay.com/sh/ord/?filter=status%3AALL_ORDERS%2Ctimerange%3APREVIOUSMONTH')
if page.title != "Security Measure":login(page, username_str, password_str)

3、将验证码截图获取图片并转为base64编码

def land():page.get_screenshot(path='tmp', name='pic.jpg', full_page=True)rangle = (74, 10, 474, 610)  # 左、上、右、下img = Image.open(r'tmp/pic.jpg')cropped_img = img.crop(rangle)# 保存裁剪后的图片cropped_img.save(r'tmp/cropped_image.png')title = (79, 15, 464, 130)img.crop(title).save(r"tmp/title.png")reader = easyocr.Reader(['ch_sim', 'en'])result = reader.readtext(img)title_list = []for detection in result:print(detection[1])title_list.append(detection[1])img1 = (79, 135, 209, 260)img.crop(img1).save(r"tmp/img1.png")img2 = (209, 135, 339, 260)img.crop(img2).save(r"tmp/img2.png")img3 = (339, 135, 469,260)img.crop(img3).save(r"tmp/img3.png")img4 = (79, 265, 209, 395)img.crop(img4).save(r"tmp/img4.png")img5 = (209, 265, 339, 395)img.crop(img5).save(r"tmp/img5.png")img6 = (339, 265, 469, 395)img.crop(img6).save(r"tmp/img6.png")img7 = (79, 395, 209, 525)img.crop(img7).save(r"tmp/img7.png")img8 = (209, 395, 339, 525)img.crop(img8).save(r"tmp/img8.png")img9 = (339, 395, 469, 525)img.crop(img9).save(r"tmp/img9.png")base64_list = []for i in range(1, 10):with  open(f'tmp/img{i}.png', "rb") as img_file:encoded_string = base64.b64encode(img_file.read()).decode('utf-8')base64_list.append(encoded_string)return base64_list,title_list

4、将图片列表和标题传入图片识别api返回目标坐标,模拟完成点击

res = get_rect(base64_list, 'tmp/title.png')
objects = res["solution"]["objects"]
img_list = [img1, img2, img3, img4, img5, img6, img7, img8, img9]
print("1111", objects)
for i in range(9):if objects[i]:target = ((int(img_list[i][0]) + int(img_list[i][2])) / 2, (int(img_list[i][1]) + int(img_list[i][3])) / 2)page.actions.move_to(target).click()time.sleep(1)
http://www.xdnf.cn/news/5693.html

相关文章:

  • http接口性能优化方案
  • uniapp|实现手机通讯录、首字母快捷导航功能、多端兼容(H5、微信小程序、APP)
  • 键盘输出希腊字符方法
  • .net 公共变量 线程安全
  • 高并发内存池(三):TLS无锁访问以及Central Cache结构设计
  • Python文字转语音TTS库示例(edge-tts)
  • keil 解决 Error: CreateProcess failed, Command: ‘XXX\ARM\ARMCC\bin\fromelf.exe
  • 精益数据分析(55/126):双边市场模式的挑战、策略与创业阶段关联
  • Leetcode (力扣)做题记录 hot100(34,215,912,121)
  • 软件设计师-错题笔记-系统开发与运行
  • 吊舱的热灵敏度技术要点
  • 【Linux网络】————HTTP协议详解
  • MySQL全量,增量备份与恢复
  • Netty在Java网络编程中的应用:实现高性能的异步通信
  • 线下消费经济“举步维艰”,开源AI智能名片链动2+1+S2B2C小程序线上“狂飙突进”!
  • springboot集成langchain4j实现票务助手实战
  • 【软考-高级】【信息系统项目管理师】论文写作注意事项及2014年至2024年历年论文题目汇总
  • sqlilab-Less-18
  • 【第四批】运行时应用程序自我保护(RASP)工具能力通过评估名单
  • 【Dv3Admin】工具数据验证配置文件解析
  • 网卡网孔速率的协商是如何进行的?
  • 【Rust泛型】Rust泛型使用详解与应用场景
  • 力扣HOT100之二叉树:104. 二叉树的最大深度
  • 软件安全之内存泄漏
  • 构造+简单树状
  • 搜索二维矩阵 II 算法讲解
  • OpenHarmony 开源鸿蒙南向开发——linux下使用make交叉编译第三方库——gnutls
  • AD开启交叉选择功能,只选中器件,不选中网络、焊盘
  • PostgreSQL 序列(Sequence) 与 Oracle 序列对比
  • 聊一聊常见的超时问题:timeout