手搓一个谷歌过验证码的,下面是视频和相关代码
# 使用提醒:
# 1. xbot包提供软件自动化、数据表格、Excel、日志、AI等功能
# 2. package包提供访问当前应用数据的功能,如获取元素、访问全局变量、获取资源文件等功能
# 3. 当此模块作为流程独立运行时执行main函数
# 4. 可视化流程中可以通过"调用模块"的指令使用此模块
import xbot
from xbot import print, sleep
from .import package
from .package import variables as glv
import time
import requests
import json
import base64
def main(args):
pass
def image_to_base64(file_path):
with open(file_path, "rb") as image_file:
base64_bytes = base64.b64encode(image_file.read())
base64_string = base64_bytes.decode("utf-8")
return base64_string
# 示例:转换图片为 Base64
def find_index(img,question):
base64_data = image_to_base64(img)
url = "https://api.yescaptcha.com/createTask"
payload = {
"clientKey": "ed17219d97221ff857cf7f763f7b42e74dbcc85868102",
"task": {
"type": "FunCaptchaClassification",
"image": base64_data,
"question": question
}
}
headers = {'Content-Type': 'application/json'}
response = requests.post(url, data=json.dumps(payload), headers=headers)
response = json.loads(response.text)
# print(response["taskId"])
url = "https://api.yescaptcha.com/getTaskResult"
payload = {
"clientKey": "ed17219d97221ff857cf7f763f7b42e74dbcc85868102",
"taskId": response["taskId"]
}
headers = {'Content-Type': 'application/json'}
response = requests.post(url, data=json.dumps(payload), headers=headers)
return json.loads(response.text)["solution"]["objects"]
# "//div[@aria-label="1,共 5 项"]"