Shopee 验证码
概述
Shopee 验证码是 Shopee 使用的验证码系统,用于保护用户和系统免受异常行为(如机器人、垃圾邮件或自动登录)的影响。
Achicaptcha 支持为多种不同平台(浏览器、模拟器、手机)自动解决 Shopee 验证码。请参阅下面的指南来集成 API。
🛍️
对于 Shopee 的文字验证码,请参考 文字验证码。如有问题,请联系 管理员 (opens in a new tab) 获取支持。


1. 创建任务
请求
POST https://api.achicaptcha.com/createTask
参数
| 参数名 | 数据类型 | 必需? | 描述 |
|---|---|---|---|
clientKey | string | yes | API 密钥 |
task.type | string | yes | ShopeeCaptchaTask |
task.image | string | yes | 掩码图像的 Base64|背景图像的 Base64 |
task.subType | int | yes | 验证码类型: 0:滑块验证码 |
请求示例
POST /createTask HTTP/1.1
Host: api.achicaptcha.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "ShopeeCaptchaTask",
"image": "/9j/4AAQSkZJRgABAQEASABIAAD...|/9j/4DSJFHKSDJDS...",
"subType": 0
}
}响应
成功时,服务器将返回 errorId = 0 和 taskId
{
"errorId": 0,
"taskId": "f2fc70d6-c76b-4fba-9480-205ac1fe9fb9"
}2. 获取结果
请求
POST https://api.achicaptcha.com/getTaskResult
参数
| 参数名 | 数据类型 | 必需? | 描述 |
|---|---|---|---|
clientKey | string | yes | API 密钥,联系管理员 |
taskId | string | yes | 从 (1) 获取的 TaskId |
请求示例
POST /getTaskResult HTTP/1.1
Host: api.achicaptcha.com
Content-Type: application/json
{
"clientKey": "您的 API_KEY",
"taskId": "f2fc70d6-c76b-4fba-9480-205ac1fe9fb9"
}响应
{
"errorId": 0,
"status": "ready",
"solution": "x1,y1,x2,y2"
}返回结果的含义
errorId = 0且status = ready:解决成功,在solution中读取结果errorId = 1且status = processing:正在解决验证码,等待 1-2 秒后重试errorId 非 0 和 1:系统错误,返回错误代码和错误描述solution:对于滑块验证码:返回需要沿图像 x 轴拖动的坐标
集成示例
import requests
import time
def solve_shopee_captcha(mask_image, bg_image, sub_type, api_key='YOUR_API_KEY'):
# 步骤 1:创建任务
create_task_url = 'https://api.achicaptcha.com/createTask'
create_task_payload = {
'clientKey': api_key,
'task': {
'type': 'ShopeeCaptchaTask',
'image': mask_image + '|' + bg_image,
'subType': sub_type
}
}
response = requests.post(create_task_url, json=create_task_payload)
result = response.json()
if result['errorId'] != 0:
raise Exception(result['errorDescription'])
task_id = result['taskId']
# 步骤 2:获取结果
get_result_url = 'https://api.achicaptcha.com/getTaskResult'
while True:
time.sleep(2) # 等待 2 秒
get_result_payload = {
'clientKey': api_key,
'taskId': task_id
}
response = requests.post(get_result_url, json=get_result_payload)
result = response.json()
if result['errorId'] == 0 and result['status'] == 'ready':
return result['solution']
if result['errorId'] != 0 and result['errorId'] != 1:
raise Exception(result['errorDescription'])
# 如果 status == 'processing',继续循环
# 使用
mask_image = '/9j/4AAQSkZJRgABAQEASABIAAD...' # 掩码图像的 Base64
bg_image = '/9j/4DSJFHKSDJDS...' # 背景图像的 Base64
sub_type = 0 # 0:滑块验证码
solution = solve_shopee_captcha(mask_image, bg_image, sub_type, 'YOUR_API_KEY')
print('Shopee 验证码解决方案:', solution)常见错误代码
创建任务时的错误代码
| 错误代码 | 描述 | 注释 |
|---|---|---|
| 0 | success | 创建任务成功 |
| 2 | missing required fields | 缺少必需字段,检查参数(image、subType) |
| 3 | task not supported | 不支持的任务类型 |
| 4 | task creation failed | 创建任务失败,稍后重试 |
| 5 | client key does not exist | API 密钥不存在,检查 API 密钥 |
| 6 | insufficient account balance | 账户余额不足,充值积分 |
获取结果时的错误代码
| 错误代码 | 描述 | 注释 |
|---|---|---|
| 0 | success | 成功,在 solution 字段中读取结果 |
| 1 | processing | 正在处理,等待 1-2 秒后重新发送请求 |
| 5 | client key does not exist | API 密钥不存在,检查 API 密钥 |
| 7 | task failed, please create a new task | 任务失败,请创建新任务 |
| 8 | task ID does not exist | 任务 ID 不存在或已过期 |
最佳实践
为了在使用 Achicaptcha API 解决 Shopee 验证码时获得最佳效果,请遵循以下原则:
1. 准备 Base64 图像
- 将掩码和背景图像转换为 Base64 格式
- 确保图像质量清晰以提高准确性
- 使用
|(管道)字符连接两个图像
2. 轮询间隔
- 在结果检查之间至少等待 1-2 秒
- 不要用太多连续请求轰炸 API
- 设置超时以避免无限循环(建议 120 秒)
3. 错误处理
- 检查
errorId以检测错误 errorId = 0且status = ready:成功errorId = 1:正在处理,继续轮询errorId 非 0 和 1:系统错误,需要处理
4. 重试逻辑
- 为临时错误实施重试
- 重试时使用指数退避
- 限制最大重试次数
5. API 密钥安全
- 不要在代码中硬编码 API 密钥
- 使用环境变量
- 不要在客户端暴露 API 密钥
有用的链接: