Files
weidian/README.md

44 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Weidian Snatch (微店抢购脚本)
这是一个基于 [Playwright](https://playwright.dev/) 的微店自动抢购工具,支持精确计时、自动登录、隐身模式等功能。
## 功能特性
- **自动登录**:支持保存和加载登录状态 (`auth_state.json`)。
- **精确计时**:内置 `PrecisionTimer` 进行时间同步和倒计时等待。
- **隐身模式**:使用 stealth 脚本隐藏自动化特征,降低防爬虫检测风险。
- **自动抢购**自动执行点击购买、确认规格SKU、提交订单的流程。
## 文件结构
- `main.py`: 主程序入口,包含抢购的核心逻辑。
- `config.yaml`: 配置文件,设置商品链接、抢购时间、浏览器模式等。
- `resolve_url.py`: URL 解析工具(如果有)。
- `utils/`:
- `auth.py`: 处理用户认证和 Session 管理。
- `stealth.py`: 反爬虫隐身处理。
- `timer.py`: 时间同步与控制。
## 使用方法
1. **安装依赖**
请确保已安装 Python并安装所需的库
```bash
pip install playwright pyyaml
playwright install
```
2. **配置 config.yaml**
修改 `config.yaml` 文件,填入目标商品 URL (`target_url`) 和抢购时间 (`snatch_time`)。
3. **运行脚本**
```bash
python main.py
```
如果是首次运行且无登录状态,脚本会提示登录。请手动登录后,脚本会自动保存状态供下次使用。
## 注意事项
- 请确保网络畅通,以保证时间同步和抢购请求的及时发送。
- 抢购成功率受多种因素影响(网络延迟、库存数量、平台风控等),本脚本仅辅助操作,不保证 100% 成功。