'init'
This commit is contained in:
258
README.md
Normal file
258
README.md
Normal file
@@ -0,0 +1,258 @@
|
||||
# MIP页广告自动点击服务
|
||||
|
||||
基于 AdsPower 的 MIP 页面广告自动化点击系统,支持自动识别商业广告、智能点击策略和数据统计反馈。
|
||||
|
||||
## 功能特性
|
||||
|
||||
- 自动识别 MIP 页面中的商业广告(排除 AI 健康管家等非商业内容)
|
||||
- 智能点击策略:随机点击次数、固定间隔时间、工作时间限制
|
||||
- 自动等待广告主回复并记录
|
||||
- 完整的数据统计和反馈机制
|
||||
- RESTful API 接口,支持运营人员提交链接
|
||||
- 持久化存储,支持断点续传
|
||||
|
||||
## 系统要求
|
||||
|
||||
- Python 3.8+
|
||||
- AdsPower 浏览器客户端
|
||||
- Chrome/Chromium 浏览器
|
||||
|
||||
## 安装步骤
|
||||
|
||||
### 1. 克隆或下载项目
|
||||
|
||||
```bash
|
||||
cd d:\project\Work\ai_mip
|
||||
```
|
||||
|
||||
### 2. 创建虚拟环境(推荐)
|
||||
|
||||
```bash
|
||||
python -m venv venv
|
||||
venv\Scripts\activate # Windows
|
||||
```
|
||||
|
||||
### 3. 安装依赖
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### 4. 配置环境变量
|
||||
|
||||
复制 `.env.example` 为 `.env` 并修改配置:
|
||||
|
||||
```bash
|
||||
copy .env.example .env
|
||||
```
|
||||
|
||||
编辑 `.env` 文件,配置以下关键参数:
|
||||
|
||||
```env
|
||||
# AdsPower配置
|
||||
ADSPOWER_API_URL=http://local.adspower.net:50325
|
||||
ADSPOWER_USER_ID=your_user_id_here
|
||||
|
||||
# 点击策略配置
|
||||
MIN_CLICK_COUNT=1
|
||||
MAX_CLICK_COUNT=10
|
||||
CLICK_INTERVAL_MINUTES=30
|
||||
WORK_START_HOUR=9
|
||||
WORK_END_HOUR=21
|
||||
REPLY_WAIT_TIMEOUT=30
|
||||
```
|
||||
|
||||
## 使用说明
|
||||
|
||||
### 启动服务
|
||||
|
||||
```bash
|
||||
python app.py
|
||||
```
|
||||
|
||||
服务默认运行在 `http://localhost:5000`
|
||||
|
||||
### API 接口
|
||||
|
||||
#### 1. 健康检查
|
||||
|
||||
```bash
|
||||
GET /health
|
||||
```
|
||||
|
||||
#### 2. 添加单个 URL
|
||||
|
||||
```bash
|
||||
POST /api/urls
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"url": "https://example.com/mip-page"
|
||||
}
|
||||
```
|
||||
|
||||
#### 3. 批量添加 URL
|
||||
|
||||
```bash
|
||||
POST /api/urls
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"urls": [
|
||||
"https://example.com/mip-page-1",
|
||||
"https://example.com/mip-page-2"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### 4. 获取所有 URL 列表
|
||||
|
||||
```bash
|
||||
GET /api/urls
|
||||
```
|
||||
|
||||
响应示例:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": [
|
||||
{
|
||||
"url": "https://example.com/mip-page",
|
||||
"status": "active",
|
||||
"target_clicks": 5,
|
||||
"click_count": 2,
|
||||
"reply_count": 1,
|
||||
"created_time": "2026-01-12T10:00:00",
|
||||
"last_click_time": "2026-01-12T11:30:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### 5. 获取 URL 详细信息
|
||||
|
||||
```bash
|
||||
GET /api/urls/{url}
|
||||
```
|
||||
|
||||
#### 6. 删除 URL
|
||||
|
||||
```bash
|
||||
DELETE /api/urls/{url}
|
||||
```
|
||||
|
||||
#### 7. 重置 URL(重新开始点击)
|
||||
|
||||
```bash
|
||||
POST /api/urls/{url}/reset
|
||||
```
|
||||
|
||||
#### 8. 获取统计数据
|
||||
|
||||
```bash
|
||||
GET /api/statistics
|
||||
```
|
||||
|
||||
响应示例:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"total_urls": 10,
|
||||
"active_urls": 5,
|
||||
"completed_urls": 4,
|
||||
"failed_urls": 1,
|
||||
"total_clicks": 35,
|
||||
"total_replies": 28,
|
||||
"reply_rate": "80.00%"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 9. 调度器控制
|
||||
|
||||
启动调度器:
|
||||
```bash
|
||||
POST /api/scheduler/start
|
||||
```
|
||||
|
||||
停止调度器:
|
||||
```bash
|
||||
POST /api/scheduler/stop
|
||||
```
|
||||
|
||||
查看调度器状态:
|
||||
```bash
|
||||
GET /api/scheduler/status
|
||||
```
|
||||
|
||||
## 点击策略说明
|
||||
|
||||
系统会根据以下策略自动执行点击任务:
|
||||
|
||||
1. **随机点击次数**:每个 URL 的目标点击次数在 1-10 次之间随机生成
|
||||
2. **点击间隔**:同一 URL 两次点击之间至少间隔 30 分钟
|
||||
3. **工作时间**:仅在 09:00-21:00 之间执行点击任务
|
||||
4. **回复等待**:点击广告后等待 30 秒检测广告主回复
|
||||
|
||||
## 广告识别逻辑
|
||||
|
||||
系统会自动识别 MIP 页面中的商业广告:
|
||||
|
||||
- ✅ **点击**:带有"广告"标识的商业广告
|
||||
- ❌ **跳过**:无广告的页面
|
||||
- ❌ **跳过**:AI 健康管家等非商业内容
|
||||
|
||||
## 数据存储
|
||||
|
||||
所有数据存储在 `./data/urls_data.json` 文件中,包括:
|
||||
|
||||
- URL 列表和状态
|
||||
- 点击统计
|
||||
- 回复统计
|
||||
- 点击历史记录
|
||||
|
||||
## 日志
|
||||
|
||||
日志文件存储在 `./logs/` 目录下,包含详细的运行日志和错误信息。
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
ai_mip/
|
||||
├── app.py # Flask 应用主入口
|
||||
├── config.py # 配置管理
|
||||
├── adspower_client.py # AdsPower API 客户端
|
||||
├── ad_automation.py # 广告自动化操作
|
||||
├── scheduler.py # 点击任务调度器
|
||||
├── data_manager.py # 数据存储管理
|
||||
├── requirements.txt # Python 依赖
|
||||
├── .env.example # 环境变量示例
|
||||
├── .gitignore # Git 忽略配置
|
||||
├── README.md # 项目文档
|
||||
└── data/ # 数据目录(自动创建)
|
||||
└── urls_data.json # URL 数据文件
|
||||
└── logs/ # 日志目录(自动创建)
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **AdsPower 配置**:确保 AdsPower 客户端已安装并运行,正确配置 `ADSPOWER_USER_ID`
|
||||
2. **页面结构适配**:如果实际 MIP 页面结构与预期不同,需要修改 `ad_automation.py` 中的元素选择器
|
||||
3. **网络环境**:确保网络稳定,能够正常访问目标 MIP 页面
|
||||
4. **浏览器驱动**:AdsPower 会自动管理 ChromeDriver,无需手动配置
|
||||
|
||||
## 常见问题
|
||||
|
||||
### Q: 启动服务后无法连接 AdsPower?
|
||||
A: 检查 AdsPower 是否正在运行,API 地址是否正确(默认:http://local.adspower.net:50325)
|
||||
|
||||
### Q: 无法识别广告?
|
||||
A: 需要根据实际页面结构调整 `ad_automation.py` 中的广告识别逻辑和选择器
|
||||
|
||||
### Q: 如何查看点击记录?
|
||||
A: 调用 `/api/statistics` 接口查看整体统计,或使用 `/api/urls/{url}` 查看单个 URL 的详细点击历史
|
||||
|
||||
## 技术支持
|
||||
|
||||
如有问题,请查看日志文件或联系开发团队。
|
||||
Reference in New Issue
Block a user