Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GLM Coding 抢购脚本

智谱 GLM Coding 套餐自动抢购工具,基于油猴脚本 + 本地 ddddocr 验证码识别服务。

功能

  • 验证码自动识别:本地 ddddocr 引擎,识别速度约 100ms
  • 自动锁单:preview 成功后自动调 create-sign 锁单,跳过页面跳转延迟
  • 服务器时钟校准:自动测量本地与服务器时间偏移,精确卡点
  • 预存 ticket:抢购前提前解验证码缓存 ticket,到点直接用
  • 防检测限流:preview 对齐整 10 秒边界,每分钟 ≤6 次,规避 555
  • 调剂模式:售罄后自动切换其他套餐
  • 代理池:支持 HTTP/SOCKS5 代理轮换,规避 IP 限流
  • 自动重登:token 失效时自动用账密刷新

项目结构

glm-coding-grabber/
├── index-v2.js                  # 油猴脚本 (v3.0.0)
├── captcha/
│   ├── ddddocr_server_win.py    # 验证码识别服务 + 代理转发 (Windows)
│   ├── ddddocr_server.py        # 验证码识别服务 (macOS/Linux)
│   ├── requirements.txt         # Python 依赖
│   ├── proxy.conf               # 代理池配置文件
│   └── readme.md                # 验证码服务说明
└── docs/
    ├── 部署踩坑记录.txt
    └── 启动验证码服务.bat

部署

1. 安装 Python 3.13

下载地址:https://www.python.org/downloads/release/python-3135/

⚠️ 不要用 Python 3.14(onnxruntime 无兼容版本)或 3.8(代码用了 3.9+ 语法)

2. 安装依赖

cd captcha
pip install -r requirements.txt

依赖说明:

包 版本约束 说明
ddddocr >=1.5.0 OCR 识别引擎
flask >=3.0 HTTP 服务框架
Pillow >=10.0 图片处理
onnxruntime ==1.20.1 ddddocr 依赖,新版 DLL 不兼容
opencv-python <5 5.0 移除了 HOGDescriptor
PySocks >=1.7.1 SOCKS5 代理支持(可选)

3. 启动验证码服务

Windows:

cd captcha
python ddddocr_server_win.py

代理通过配置文件管理,编辑 captcha/proxy.conf:

# 每行一个代理地址,# 开头是注释
# 留空 = 不使用代理,直连转发
http://1.2.3.4:8080
socks5://5.6.7.8:1080
http://admin:123456@9.10.11.12:3128

修改后重启服务生效。

验证服务是否启动:

curl http://127.0.0.1:9898/health

返回 {"status":"ok","engine":"ddddocr","fonts":N} 即正常。

4. 安装油猴脚本

  1. 安装 Tampermonkey 浏览器扩展
  2. 打开 Tampermonkey → 管理面板 → 实用工具
  3. 「从文件导入」选择 index-v2.js
  4. 点击安装

5. 使用

  1. 启动本地验证码服务
  2. 访问智谱 GLM Coding 页面
  3. 在控制面板设置套餐、档位、抢购时间
  4. 勾选 自动预存 和 防检测
  5. 预存数量设为 5,间隔设为 100ms
  6. 点击 开始抢购

代理配置

代理池用于让 preview 请求和验证码请求通过不同 IP 出口,规避服务端 IP 限流。

支持的代理类型

类型 格式 示例
HTTP http://ip:port http://1.2.3.4:8080
HTTP(带认证) http://user:pass@ip:port http://admin:123@1.2.3.4:8080
SOCKS5 socks5://ip:port socks5://5.6.7.8:1080
SOCKS5(带认证) socks5://user:pass@ip:port socks5://admin:123@5.6.7.8:1080

配置方式

编辑 captcha/proxy.conf 文件,每行一个代理地址:

http://1.2.3.4:8080
socks5://5.6.7.8:1080
http://admin:123456@9.10.11.12:3128
  • # 开头的行是注释
  • 留空(全部注释或不填)= 直连转发,不使用代理
  • 修改后重启服务生效

SOCKS5 依赖

使用 SOCKS5 代理需额外安装 PySocks:

pip install PySocks

抢购优化说明

本项目在原版 v3.0.0 基础上做了以下优化:

优化项 原版 优化后 效果
发请求时机 到点后 提前 300ms 利用网络延迟卡点
到点等待 sleep(500ms) 立即开始 不浪费时间
预存 token 间隔 1800ms 100ms 5 个 token 在 500ms 内全打出
Phase 1 防检测 对齐整 10 秒 跳过 开抢瞬间 burst
Phase 2 防检测 对齐整 10 秒 保持 持续重试不触发 555
Phase 2 重试间隔 800ms 300ms 快速重试
预存数量 1 5 更多穿透机会
SDK 清理等待 1000ms 300ms 快速重试

到点后请求时序

09:59:59.700  提前 300ms 开火,发 token #1
09:59:59.800  发 token #2
09:59:59.900  发 token #3
10:00:00.000  发 token #4
10:00:00.100  发 token #5
              ↓ 5 个请求在 500ms 内全打出
10:00:00.500  Phase 2 恢复防检测,对齐整 10 秒
10:00:10.000  第一个防检测 preview
10:00:20.000  第二个防检测 preview

接口文档

POST /click

识别点选验证码。

// 请求
{ "image": "<base64>", "remark": "大中小" }

// 响应
{ "success": true, "data": { "result": "x1,y1|x2,y2|x3,y3", "id": "" } }

GET /health

健康检查。

{ "status": "ok", "engine": "ddddocr", "fonts": 14 }

POST /proxy

代理转发请求。

// 请求
{ "method": "POST", "url": "https://...", "headers": {}, "body": "...", "session": "abc" }

// 响应
{ "success": true, "status": 200, "headers": {}, "body": "<base64>", "proxy": "http://1.2.3.4:8080" }

session 用于出口粘性:同一 session 值会固定使用同一个代理 IP。

常见问题

ImportError: DLL load failed while importing onnxruntime_pybind11_state

onnxruntime 新版 DLL 不兼容,降级:

pip install onnxruntime==1.20.1

AttributeError: module 'cv2' has no attribute 'HOGDescriptor'

OpenCV 5.0 移除了 HOGDescriptor,降级:

pip install "opencv-python<5"

TypeError: 'type' object is not subscriptable

Python 3.8 不支持 list[dict] 语法,需 Python 3.9+。

Error while finding module specification for 'ddddocr_server_win.py'

多了 -m 参数,去掉:

# 错误
python -m ddddocr_server_win.py
# 正确
python ddddocr_server_win.py

免责声明

本项目仅用于本地 OCR、自动化辅助及技术学习与研究,请遵守目标网站服务条款及相关法律法规。因使用本脚本产生的一切后果由使用者自行承担。

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages