Install
openclaw skills install competitor-monitor-ai竞品数据定时监控Skill,定时访问指定电商或社交平台页面,抓取点赞、评论、销量等数据,检测数据异常波动(如出现爆款),自动截图并发送提醒通知。适用于竞品分析、市场监控、爆款发现等场景。
openclaw skills install competitor-monitor-ai本 Skill 用于定时监控竞品在电商平台或社交平台的数据表现,帮助用户:
创建监控配置文件 config/monitor_tasks.json:
{
"tasks": [
{
"id": "task_001",
"name": "竞品A-抖音监控",
"platform": "douyin",
"url": "https://www.douyin.com/video/xxxxx",
"schedule": "0 */2 * * *",
"metrics": ["likes", "comments", "shares", "views"],
"alert_threshold": {
"likes": {"increase_percent": 50, "min_value": 1000},
"comments": {"increase_percent": 30, "min_value": 100}
}
},
{
"id": "task_002",
"name": "竞品B-小红书监控",
"platform": "xiaohongshu",
"url": "https://www.xiaohongshu.com/explore/xxxxx",
"schedule": "0 */4 * * *",
"metrics": ["likes", "collections", "comments"],
"alert_threshold": {
"likes": {"increase_percent": 100, "min_value": 500}
}
}
]
}
# 启动监控服务
python scripts/monitor_service.py --config assets/config/monitor_tasks.json
# 后台运行
nohup python scripts/monitor_service.py --config assets/config/monitor_tasks.json > monitor.log 2>&1 &
当检测到数据异常时:
assets/screenshots/{
"tasks": [
{
"id": "任务ID",
"name": "任务名称",
"platform": "平台类型",
"url": "监控页面URL",
"schedule": "定时规则(cron格式)",
"metrics": ["监控指标列表"],
"selectors": {
"likes": "点赞数CSS选择器",
"comments": "评论数CSS选择器"
},
"alert_threshold": {
"指标名": {
"increase_percent": "增长率阈值(%)",
"min_value": "最小触发值"
}
},
"screenshot_on_alert": true,
"notification": {
"email": ["email@example.com"],
"webhook": "https://oapi.dingtalk.com/robot/send?access_token=xxx"
}
}
],
"global": {
"data_retention_days": 30,
"screenshot_retention_days": 7,
"default_schedule": "0 */6 * * *"
}
}
Skill内置了常见平台的CSS选择器预设:
| 平台 | 点赞 | 评论 | 分享/转发 | 播放量/浏览 |
|---|---|---|---|---|
| 抖音 | .like-count | .comment-count | .share-count | .play-count |
| 小红书 | .like-count | .comment-count | .collect-count | - |
| 微博 | .like-count | .comment-count | .repost-count | .read-count |
| B站 | .like-count | .comment-count | .coin-count | .view-count |
| 淘宝 | - | .rate-count | - | .sell-count |
* * * * *
│ │ │ │ │
│ │ │ │ └─── 星期 (0-7, 0和7都是周日)
│ │ │ └───── 月份 (1-12)
│ │ └─────── 日期 (1-31)
│ └───────── 小时 (0-23)
└─────────── 分钟 (0-59)
示例:
0 */2 * * * # 每2小时
0 9,18 * * * # 每天9点和18点
0 */6 * * 1-5 # 工作日每6小时
增长率检测
绝对值检测
趋势检测
爆款检测
{
"alert_threshold": {
"likes": {
"increase_percent": 50,
"min_value": 1000,
"window": "2h"
},
"comments": {
"increase_percent": 30,
"min_value": 100
},
"views": {
"increase_percent": 100,
"min_value": 10000
}
},
"burst_detection": {
"enabled": true,
"min_metrics": 2,
"threshold": {
"likes": 5000,
"comments": 500,
"shares": 1000
}
}
}
{
"notification": {
"email": {
"smtp_server": "smtp.qq.com",
"smtp_port": 587,
"username": "your_email@qq.com",
"password": "your_auth_code",
"to": ["recipient@example.com"]
}
}
}
{
"notification": {
"dingtalk": {
"webhook": "https://oapi.dingtalk.com/robot/send?access_token=xxx",
"secret": "your_secret"
}
}
}
{
"notification": {
"feishu": {
"webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/xxx"
}
}
}
{
"notification": {
"wecom": {
"webhook": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx"
}
}
}
assets/data/
├── raw/ # 原始抓取数据
│ ├── task_001/
│ │ ├── 2024-01-15.json
│ │ └── 2024-01-16.json
│ └── task_002/
├── processed/ # 处理后数据
│ └── trends/
└── alerts/ # 异常记录
└── 2024-01-16.json
{
"task_id": "task_001",
"timestamp": "2024-01-16T10:00:00",
"url": "https://...",
"data": {
"likes": 15234,
"comments": 892,
"shares": 3456,
"views": 125000
},
"changes": {
"likes": {"value": 1234, "percent": 8.8},
"comments": {"value": 89, "percent": 11.1}
},
"alert_triggered": false
}
cp assets/config/monitor_tasks.example.json assets/config/monitor_tasks.json
vim assets/config/monitor_tasks.json
python scripts/monitor_service.py start
# 添加监控任务
python scripts/monitor_cli.py add --name "竞品A" --url "https://..." --platform douyin
# 列出所有任务
python scripts/monitor_cli.py list
# 手动执行一次监控
python scripts/monitor_cli.py run --task task_001
# 查看监控数据
python scripts/monitor_cli.py data --task task_001 --days 7
# 生成趋势报告
python scripts/monitor_cli.py report --task task_001 --output report.html
# 停止监控服务
python scripts/monitor_service.py stop
# 单次抓取数据
python scripts/scraper.py --url "https://..." --platform douyin --output data.json
# 带截图
python scripts/scraper.py --url "https://..." --platform douyin --screenshot
pip install playwright schedule pandas requests
playwright install chromium
| 模块 | 功能 |
|---|---|
scraper.py | 网页数据抓取 |
detector.py | 异常检测算法 |
notifier.py | 通知发送 |
scheduler.py | 定时任务调度 |
storage.py | 数据存储管理 |
monitor_service.py | 监控服务主程序 |
competitor-monitor/
├── SKILL.md # Skill主文件
├── README.md # 使用说明
├── INSTALL_GUIDE.md # 安装指南
├── install.sh # 安装脚本
├── scripts/
│ ├── monitor_service.py # 监控服务主程序
│ ├── monitor_cli.py # 命令行工具
│ ├── scraper.py # 数据抓取模块
│ ├── detector.py # 异常检测模块
│ ├── notifier.py # 通知模块
│ ├── scheduler.py # 定时任务模块
│ ├── storage.py # 数据存储模块
│ └── dashboard.py # 数据可视化
├── assets/
│ ├── config/
│ │ ├── monitor_tasks.example.json # 配置示例
│ │ └── platforms.json # 平台预设配置
│ ├── screenshots/ # 截图存档
│ └── data/ # 数据存档
└── references/
└── PLATFORM_SELECTORS.md # 平台选择器参考
{
"id": "douyin_001",
"name": "竞品抖音视频监控",
"platform": "douyin",
"url": "https://www.douyin.com/video/1234567890",
"schedule": "0 */2 * * *",
"metrics": ["likes", "comments", "shares"],
"alert_threshold": {
"likes": {"increase_percent": 50, "min_value": 5000}
},
"screenshot_on_alert": true
}
{
"id": "xhs_001",
"name": "小红书爆款监控",
"platform": "xiaohongshu",
"url": "https://www.xiaohongshu.com/explore/abcdef",
"schedule": "0 */4 * * *",
"metrics": ["likes", "collections", "comments"],
"alert_threshold": {
"likes": {"increase_percent": 100, "min_value": 1000},
"collections": {"increase_percent": 80, "min_value": 500}
},
"burst_detection": {
"enabled": true,
"min_metrics": 2
}
}
{
"id": "taobao_001",
"name": "竞品销量监控",
"platform": "taobao",
"url": "https://item.taobao.com/item.htm?id=123456",
"schedule": "0 9,18 * * *",
"metrics": ["sell_count", "rate_count", "price"],
"alert_threshold": {
"sell_count": {"increase_percent": 30, "min_value": 100}
}
}