Files
ProxyPool/README.md
祀梦 0131c8b408 feat: fpw plugins, validation/crawl perf, WS stats, test DB isolation
- Add Free_Proxy_Website-style fpw_* plugins and register them
- Per-plugin crawl timeout (crawl_timeout_seconds=120); remove global crawl_timeout setting
- Validator: fix connect vs total timeout on save; SOCKS session LRU cache; drop redundant semaphore
- Validation handler uses single DB connection; batch upsert after crawl; WorkerPool put_nowait
- Remove unused max_retries from settings API/UI; settings maintenance SQL + init_db cleanup of deprecated keys
- WebSocket dashboard stats; ProxyList pool_filter and API alignment
- POST /api/proxies/delete-one for IPv6-safe deletes; task poll stops on 404
- pytest uses PROXYPOOL_DB_PATH=db/proxies.test.sqlite so tests do not wipe production DB
- .gitignore: explicit proxies.test.sqlite patterns; fix plugin_service ValidationException import

Made-with: Cursor
2026-04-05 13:39:19 +08:00

261 lines
6.3 KiB
Markdown
Raw Permalink 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.

# 代理池管理系统
现代化、科技风的代理池 WebUI 管理系统,基于 Python + Vue3 开发。
## 🌟 特性
- 🔮 **科技风设计** - 现代化的深色科技主题
- 📊 **实时监控** - 自动统计代理池状态
- 🎯 **智能管理** - 代理查询、筛选、排序、批量操作
- 📥 **多格式导出** - 支持 CSV、TXT、JSON 格式
-**自动验证** - 自动验证代理可用性并评分
- 🚀 **高性能** - 异步爬取和验证,支持高并发
## 📦 技术栈
### 后端
- **框架**: FastAPI (端口 18080)
- **数据库**: SQLite + aiosqlite
- **异步**: asyncio
### 前端
- **框架**: Vue 3 + Vite (端口 18081)
- **UI库**: Element Plus
- **状态管理**: Pinia
- **图表**: ECharts
- **样式**: CSS Variables + 深色科技风
## 🚀 快速开始
### 1. 安装后端依赖
```bash
pip install -r requirements.txt
```
### 2. 安装前端依赖
```bash
cd WebUI
npm install
```
### 3. 启动服务
#### 方式一:使用启动脚本(推荐)
```bash
cd script
start.bat
```
#### 方式二:手动启动
**启动后端服务**(终端 1
```bash
python main.py
```
**启动前端服务**(终端 2
```bash
cd WebUI
npm run dev
```
#### 停止服务
```bash
cd script
stop.bat
```
### 4. 访问 WebUI
打开浏览器访问:**http://localhost:18081**
## 📁 项目结构
```
ProxyPool/
├── main.py # 项目入口
├── requirements.txt # Python 依赖
├── .env.example # 环境变量示例
├── app/ # 后端代码
│ ├── api/ # FastAPI 路由
│ │ ├── main.py # 应用工厂
│ │ ├── routes/ # API 路由
│ │ ├── deps.py # 依赖注入
│ │ └── ...
│ ├── core/ # 核心模块
│ │ ├── config.py # 配置管理
│ │ ├── db.py # 数据库连接
│ │ ├── log.py # 日志配置
│ │ ├── plugin_system/ # 插件系统
│ │ └── tasks/ # 任务队列
│ ├── models/ # 数据模型
│ ├── repositories/ # 数据访问层
│ ├── services/ # 业务逻辑层
│ └── plugins/ # 代理源插件
│ ├── fate0.py # Fate0 代理源
│ ├── ip3366.py # IP3366 代理源
│ ├── ip89.py # IP89 代理源
│ ├── kuaidaili.py # 快代理源
│ ├── yundaili.py # 云代理源
│ ├── speedx.py # SpeedX 代理源
│ └── proxylist_download.py # ProxyList 代理源
├── WebUI/ # Vue3 前端
│ ├── src/
│ │ ├── api/ # API 封装
│ │ ├── stores/ # Pinia 状态管理
│ │ ├── views/ # 页面组件
│ │ ├── router/ # 路由配置
│ │ ├── components/ # 通用组件
│ │ └── style.css # 全局样式
│ ├── index.html
│ └── package.json
├── script/ # 启动脚本
│ ├── start.bat # Windows 启动脚本
│ └── stop.bat # Windows 停止脚本
└── db/ # 数据存储目录
└── proxies.sqlite # SQLite 数据库
```
## 🎨 主题切换
在设置页面可以切换三种科技风主题:
- **🔮 科技蓝** - 默认主题,蓝色霓虹风格
- **💜 星空紫** - 紫色星空风格
- **💚 矩阵绿** - 绿色黑客风格
## 📡 API 接口
### 统计信息
```
GET /api/stats
```
### 代理列表
```
POST /api/proxies
```
### 获取随机代理
```
GET /api/proxies/random
```
### 导出代理
```
GET /api/proxies/export/{format}
# format: csv, txt, json
```
### 删除代理
```
DELETE /api/proxies/{ip}/{port}
```
### 批量删除代理
```
POST /api/proxies/batch-delete
```
### 清理无效代理
```
DELETE /api/proxies/clean-invalid
```
### 插件列表
```
GET /api/plugins
```
### 切换插件状态
```
PUT /api/plugins/{plugin_id}/toggle
```
### 执行插件爬取
```
POST /api/plugins/{plugin_id}/crawl
```
### 系统设置
```
GET /api/settings
POST /api/settings
```
## 🐛 调试指南
### 数据不更新?
1. **检查数据库**
- 确认 `db/proxies.sqlite` 文件存在
- 使用 SQLite 客户端打开查看数据
2. **手动测试 API**
```bash
# 获取统计信息
curl http://localhost:18080/api/stats
# 获取代理列表
curl -X POST http://localhost:18080/api/proxies \
-H "Content-Type: application/json" \
-d '{"page": 1, "page_size": 20}'
```
3. **查看浏览器网络请求**
- 打开开发者工具 Network 标签
- 刷新页面查看 API 请求
- 检查响应状态码和数据
## 📝 配置说明
### 代理验证配置
- **验证超时**: 3-30秒默认 5秒
- **验证并发数**: 10-200默认 50
### 待验证与可用
- **爬取**:代理默认以「待验证」入库(`validated=0`,分数为 0不会立刻参与随机/导出。
- **验证**:在设置页「立即验证全部」或开启自动验证后,会**先验证待验证队列**,再按检查时间**复检已入库代理**;通过后标记为已验证并赋予分数。
- **设置**:「爬取后立即验证」默认关闭;开启后爬取完成会像旧版一样立刻排队验证。
### 评分机制(仅针对已验证入池的代理)
- **验证成功**: +10 分
- **验证失败**: -5 分
- **分数为 0**: 自动删除(待验证阶段验证失败则直接丢弃该条)
## 🔧 常见问题
### Q: 启动后端口被占用?
A: 修改 `.env` 中的端口号默认18080或 `WebUI/vite.config.js` 中的端口号默认18081
### Q: 爬虫无法抓取代理?
A: 检查网络连接,确保能访问目标网站,或尝试更换代理源插件
### Q: 代理验证失败率高?
A: 增加验证超时时间,或减少并发验证数量
### Q: 数据库文件在哪里?
A: 默认在 `db/proxies.sqlite`,可在 `config.py` 中修改 `DB_PATH`
### Q: 如何清空数据库?
A: 运行命令 `python -c "from core.sqlite import SQLiteManager; import asyncio; asyncio.run(SQLiteManager().clear_all())"`
## 📄 License
MIT License
## 🙏 致谢
- FastAPI - 高性能 Python Web 框架
- Vue 3 - 渐进式 JavaScript 框架
- Element Plus - 优秀的 Vue 3 UI 库
- ECharts - 强大的数据可视化库