live-forum/server/crawler/GUI_README.md
2026-03-24 11:27:37 +08:00

142 lines
3.2 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.

# 字节直播数据采集工具 - GUI 版本
将 commerce商业版和 entertainment娱乐版两个爬虫整合成一个带图形界面的桌面程序。
## 快速开始
### 步骤 1: 安装 Python
1. 下载 Python 3.10 或 3.11: https://www.python.org/downloads/
2. 安装时 **必须勾选** "Add Python to PATH"
3. 验证安装:
```
python --version
```
### 步骤 2: 安装依赖
双击运行 `setup.bat`,或在命令行执行:
```bash
cd crawler
setup.bat
```
这会自动安装:
- CustomTkinter (GUI 框架)
- PyInstaller (打包工具)
- Playwright + Chromium (浏览器自动化)
- 其他爬虫依赖
### 步骤 3: 运行 GUI
**开发模式(直接运行):**
```bash
python gui/app.py
```
**打包成 EXE**
```bash
build.bat
```
生成文件在 `dist/ByteDanceCrawler.exe`
## 文件结构
```
crawler/
├── gui/
│ ├── __init__.py
│ ├── app.py # GUI 主程序
│ └── requirements.txt # 依赖清单
├── commerce/ # 商业版爬虫
├── entertainment/ # 娱乐版爬虫
├── setup.bat # 环境安装脚本
├── build.bat # 打包脚本
├── build.spec # PyInstaller 配置
└── GUI_README.md # 本文档
```
## 功能说明
### 商业版 (巨量百应)
- **登录**: 打开浏览器登录巨量百应平台
- **查看状态**: 检查 Cookie 是否有效
- **单次抓取**: 抓取一次达人账号数据
- **启动守护**: 定时循环抓取
- **参数**:
- 每页数量: 每次抓取的数据条数
- 抓取间隔: 守护进程模式下的抓取间隔
### 娱乐版 (直播服务)
- **登录**: 打开浏览器登录直播服务平台
- **查看状态**: 检查 Cookie 是否有效
- **单次抓取**: 抓取一次排行榜数据
- **启动守护**: 定时循环抓取
- **参数**:
- 每页数量: 排行榜数据条数
- 抓取粉丝数据: 是否同时抓取主播的粉丝详情
- 抓取间隔: 守护进程模式下的抓取间隔
## 常见问题
### Q: 打包后 EXE 体积很大?
A: 正常现象。EXE 包含了:
- Python 解释器 (~30MB)
- 所有依赖库 (~50MB)
- Chromium 浏览器 (~150MB)
总体积约 250-300MB。
### Q: 杀毒软件报毒?
A: PyInstaller 打包的程序可能被误报。请添加信任或使用白名单。
### Q: 登录时浏览器没有打开?
A: 检查 Playwright 是否正确安装:
```bash
playwright install chromium
```
### Q: 打包时报错 "找不到模块"
A: 确保先运行 `setup.bat` 安装所有依赖。
### Q: 抓取数据保存在哪里?
A:
- 商业版: `commerce/data/` 目录
- 娱乐版: `entertainment/data/` 目录
### Q: 分发给其他人需要什么?
A: 只需要 `ByteDanceCrawler.exe` 一个文件,其他人双击即可运行,无需安装任何环境。
## 手动安装依赖
如果 `setup.bat` 失败,可以手动执行:
```bash
# 升级 pip
python -m pip install --upgrade pip
# 安装 GUI 依赖
pip install customtkinter pillow pyinstaller
# 安装爬虫依赖
pip install playwright requests pandas SQLAlchemy APScheduler python-dotenv loguru python-dateutil
# 安装 Chromium 浏览器
playwright install chromium
```
## 手动打包
```bash
pyinstaller build.spec --noconfirm
```