这是一个专门为Mac版微信小程序设计的智能数据捕获系统,采用MCP(模型上下文协议)架构,结合Go后端服务和Python自动化爬虫,实现微信小程序的全自动数据收集与分析。
py_scripts/
├── config.py # 配置管理 (70行)
├── wechat_window_manager.py # 微信窗口管理 (95行)
├── screenshot_manager.py # 截图管理 (85行)
├── interaction_manager.py # 交互管理 (90行)
├── analysis_client.py # 分析客户端 (85行)
├── data_manager.py # 数据管理 (95行)
├── crawler_core.py # 爬虫核心 (90行)
├── main.py # 主程序 (75行)
└── test_modules.py # 模块测试 (70行)
| 功能 | v2.0 | v2.1 |
|---|---|---|
| 代码结构 | 单文件900+行 | 🏗️ 模块化8个文件,每个文件<100行 |
| 小程序入口 | 手动操作 | 🎯 自动检测和点击 |
| 截图清理 | 手动清理 | 🧹 自动清理旧文件 |
| 代码维护 | 维护困难 | ✨ 易于维护和扩展 |
| 功能测试 | 整体测试 | 🧪 模块测试 |
# 克隆项目
git clone <repository-url>
cd mcp_wechat_mini
# 安装Go依赖
go mod tidy
# 安装Python依赖(一键脚本)
./py_scripts/install_python_dependencies.sh
# 启动MCP服务器
go run main.go
# 使用新的模块化爬虫
python3 run_crawler.py
# 或直接运行
cd py_scripts && python3 main.py
mcp_wechat_mini/
├── main.go # Go服务器入口
├── config/ # 配置管理
├── logger/ # 日志系统
├── model/ # 数据模型
├── service/ # 业务逻辑
├── controller/ # API控制器
├── py_scripts/ # Python爬虫模块
│ ├── config.py # 爬虫配置
│ ├── wechat_window_manager.py # 微信窗口管理
│ ├── screenshot_manager.py # 截图管理
│ ├── interaction_manager.py # 交互管理
│ ├── analysis_client.py # 分析客户端
│ ├── data_manager.py # 数据管理
│ ├── crawler_core.py # 爬虫核心
│ ├── main.py # 主程序
│ ├── test_modules.py # 模块测试
│ └── install_python_dependencies.sh # 依赖安装
├── run_crawler.py # 爬虫启动脚本
├── config.yaml # 服务器配置
├── USAGE_GUIDE.md # 详细使用指南
└── README.md # 项目说明
python3 run_crawler.py
crawl_results/
├── screenshots/
│ ├── 主页面_normal.png
│ ├── 主页面_full_page.png
│ └── 功能页面_normal.png
├── crawl_results_1234567890.json
└── crawl_report_1234567890.txt
{
"crawl_info": {
"app_name": "示例小程序",
"total_pages": 5,
"total_buttons": 12,
"crawl_duration": 45.6
},
"pages": [...],
"navigation_map": {...},
"feature_summary": {...}
}
cd py_scripts && python3 test_modules.py
微信小程序 → 自动入口检测 → 精准截图 → AI分析 → 结构化数据 → JSON输出
server:
address: ":8081"
readTimeout: 30s
writeTimeout: 30s
screenshot:
max_file_size: 10485760
analysis_timeout: 60
supported_formats: ["png", "jpg", "jpeg"]
# 微信窗口配置
WECHAT_WINDOW_SIZE = (400, 700)
WECHAT_WINDOW_POSITION = (100, 100)
# 小程序区域配置
MINI_PROGRAM_BOUNDS = {
'x': 150, 'y': 150,
'width': 350, 'height': 500
}
# 小程序入口按钮位置
MINI_PROGRAM_ENTRY_BOUNDS = {
'x': 30, 'y': 200,
'width': 100, 'height': 100
}
cd py_scripts && python3 test_modules.py该项目采用MIT许可证,详情参见LICENSE文档。
欢迎提交Issue和Pull Requests来改进项目!
🎯 专门针对Mac版微信小程序设计的智能爬虫系统——模块化架构,更易于维护和扩展