rank_backend/README_定时器.md
Qyir 53160420d1 Initial commit: Douyin play count tracking system
Features:
- Douyin play count scraper using Selenium + Chrome DevTools Protocol
- Automated scheduler for daily data collection
- MongoDB data storage
- Mini-program API server
- Data analysis and visualization tools

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 10:48:52 +08:00

133 lines
2.9 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.

# 抖音播放量自动抓取定时器 - 跨平台版本
## 🎯 概述
这是一个跨平台的Python定时器可以在任何电脑上运行自动在每晚22:00执行抖音播放量抓取任务。
## 📋 支持平台
-**Windows** (Windows 10/11)
-**macOS** (Intel/Apple Silicon)
-**Linux** (Ubuntu/CentOS等)
## 🚀 快速开始
### 1. 安装依赖
```bash
pip install -r config/requirements.txt
pip install schedule
```
### 2. 启动定时器
```bash
# 启动定时器
python douyin_auto_scheduler.py
# 测试模式(立即执行一次)
python douyin_auto_scheduler.py --test
# 只执行一次
python douyin_auto_scheduler.py --once
# 显示帮助
python douyin_auto_scheduler.py --help
```
### 3. 停止定时器
`Ctrl+C` 停止定时器
## 📁 文件说明
- `douyin_auto_scheduler.py` - 主定时器文件
- `start_scheduler.py` - 简化启动脚本
- `scripts/douyin_selenium_cdp_play_vv.py` - 抓取脚本
- `config/requirements.txt` - Python依赖
## ⚙️ 配置说明
### 执行时间
- **主执行时间**: 每晚 22:00
- **备用执行时间**: 每晚 22:05
### 日志文件
- 定时器日志: `logs/scheduler.log`
- 抓取任务日志: `logs/auto_update_YYYYMMDD.log`
## 🔧 使用方法
### macOS/Linux 后台运行
```bash
# 使用nohup在后台运行
nohup python douyin_auto_scheduler.py > scheduler.log 2>&1 &
# 查看进程
ps aux | grep douyin_auto_scheduler
# 停止进程
pkill -f douyin_auto_scheduler
```
### Windows 后台运行
```bash
# 使用start命令在后台运行
start /B python douyin_auto_scheduler.py
# 查看任务管理器中的Python进程
```
### 首次使用
1. 运行测试模式确保环境正常
2. 手动登录抖音账号保存登录状态
3. 启动定时器
## 🎯 功能特点
-**跨平台兼容** - 支持所有主流操作系统
-**自动执行** - 每晚22:00自动运行
-**状态监控** - 实时显示下次执行时间
-**错误恢复** - 自动重试机制
-**日志记录** - 详细的执行日志
-**数据库保存** - 自动保存到MongoDB
## 📞 故障排除
### 常见问题
1. **Python依赖问题**
```bash
pip install --upgrade pip
pip install -r config/requirements.txt
pip install schedule
```
2. **Chrome浏览器问题**
- 确保Chrome浏览器已安装
- 确保chromedriver可用
3. **MongoDB连接问题**
- 确保MongoDB服务运行
- 检查连接配置
4. **网络连接问题**
- 确保网络连接正常
- 检查防火墙设置
### 日志检查
```bash
# 查看定时器日志
tail -f logs/scheduler.log
# 查看抓取任务日志
ls -la logs/auto_update_*.log
```
## 💡 提示
- 首次使用建议先运行测试模式
- 确保计算机在22:00处于开机状态
- 定期检查日志文件确认任务正常执行
- 如需修改执行时间,编辑 `douyin_auto_scheduler.py` 中的时间设置
## 🎉 完成设置
设置完成后系统将在每晚22:00自动执行无需手动操作