Ecommerce Monitor

Other

自动监控淘宝/京东竞品价格、销量、评价,生成日报推送到飞书

Install

openclaw skills install ecommerce-monitor

电商竞对监控技能 🛍️

自动化监控淘宝、京东等电商平台的竞品数据,生成竞品分析日报


功能特性

竞品价格监控 — 实时追踪竞品价格变化 ✅ 销量数据采集 — 监控竞品销量趋势
评价分析 — 提取用户评价和评分 ✅ 日报生成 — 自动生成竞品监控日报 ✅ 飞书推送 — 推送到指定飞书群或个人 ✅ 定时任务 — 支持cron定时执行


快速开始

1. 配置监控目标

TOOLS.md 中配置监控参数:

### 电商监控配置
- 淘宝竞品链接: [竞品商品链接]
- 京东竞品链接: [竞品商品链接]
- 监控频率: 每天9点
- 飞书接收群: [飞书群ID]

2. 设置定时任务

HEARTBEAT.md 中添加定时监控:

### 电商竞对监控
- [ ] 抓取竞品数据
- [ ] 分析价格变化
- [ ] 生成日报并推送

3. 开始监控

# 手动执行监控
./scripts/ecommerce-monitor.sh

# 测试飞书推送
./scripts/feishu-test.sh

监控流程

数据采集流程

  1. 访问竞品页面
agent-browser open "https://item.taobao.com/item.htm?id=商品ID"
agent-browser open "https://item.jd.com/商品ID.html"
  1. 提取关键数据
# 价格提取
agent-browser eval "document.querySelector('.price').textContent"

# 销量提取  
agent-browser eval "document.querySelector('.sold-count').textContent"

# 评价提取
agent-browser eval "document.querySelector('.rate-count').textContent"
  1. 数据存储
{
  "product": "产品名称",
  "platform": "taobao/jd",
  "price": "129.00",
  "sales": "5000+",
  "rating": "4.8",
  "timestamp": "2026-03-26 09:00:00"
}

数据分析对比

# 价格对比分析
def analyze_price_change(current_data, previous_data):
    price_change = current_data['price'] - previous_data['price']
    change_percent = (price_change / previous_data['price']) * 100
    
    return {
        'price_change': price_change,
        'change_percent': change_percent,
        'trend': 'up' if price_change > 0 else 'down'
    }

# 销量趋势分析
def analyze_sales_trend(data_list):
    recent_sales = [d['sales'] for d in data_list[-7:]]
    trend = 'stable'
    if len(recent_sales) >= 2:
        if recent_sales[-1] > recent_sales[0]:
            trend = 'up'
        elif recent_sales[-1] < recent_sales[0]:
            trend = 'down'
    
    return trend

日报生成

日报模板

# 电商竞对监控日报 📊
**监控日期:** {{date}}
**监控产品:** {{product_count}} 个竞品

## 📈 价格变化趋势

| 产品 | 平台 | 当前价格 | 昨日价格 | 变化 | 趋势 |
|------|------|----------|----------|------|------|
| {{product1}} | 淘宝 | {{price1}} | {{yesterday1}} | {{change1}} | {{trend1}} |
| {{product2}} | 京东 | {{price2}} | {{yesterday2}} | {{change2}} | {{trend2}} |

## 📊 销量数据

| 产品 | 平台 | 当前销量 | 7日趋势 | 热销指数 |
|------|------|----------|---------|----------|
| {{product1}} | 淘宝 | {{sales1}} | {{trend1}} | {{hot1}} |

## ⭐ 用户评价

### 好评关键词
- {{positive_word1}}
- {{positive_word2}}

### 差评关键词  
- {{negative_word1}}
- {{negative_word2}}

## 💡 竞品洞察

1. **{{insight1}}**
2. **{{insight2}}**
3. **{{insight3}}**

## 🎯 行动建议

1. {{suggestion1}}
2. {{suggestion2}}

---
*数据来源: 淘宝、京东 | 生成时间: {{generate_time}}*

日报生成脚本

#!/bin/bash
# scripts/generate-report.sh

# 拉取最新数据
python scripts/fetch-data.py --output data/latest.json

# 生成日报
python scripts/generate-report.py --template daily --output reports/daily-$(date +%Y-%m-%d).md

# 推送到飞书
python scripts/send-to-feishu.py --file reports/daily-$(date +%Y-%m-%d).md --target "飞书群ID"

echo "日报已生成并推送: reports/daily-$(date +%Y-%m-%d).md"

飞书集成

飞书消息推送

# scripts/send-to-feishu.py
import requests
import json

def send_feishu_message(content, target_group):
    """发送消息到飞书群"""
    webhook_url = f"https://open.feishu.cn/open-apis/bot/v2/hook/{target_group}"
    
    payload = {
        "msg_type": "post",
        "content": {
            "post": {
                "zh_cn": {
                    "title": "电商竞对监控日报",
                    "content": content
                }
            }
        }
    }
    
    response = requests.post(webhook_url, json=payload)
    return response.status_code == 200

富文本消息格式

{
  "msg_type": "post",
  "content": {
    "post": {
      "zh_cn": {
        "title": "竞品监控日报",
        "content": [
          [
            {
              "tag": "text",
              "text": "今日监控发现:"
            },
            {
              "tag": "a",
              "text": "产品A价格下降5%",
              "href": "https://item.taobao.com/item.htm?id=xxx"
            }
          ]
        ]
      }
    }
  }
}

定时任务配置

Cron配置示例

# 每天9点执行监控
0 9 * * * /home/yesno/.openclaw/workspace/skills/ecommerce-monitor/scripts/monitor.sh

# 每小时监控一次(测试用)
0 * * * * /home/yesno/.openclaw/workspace/skills/ecommerce-monitor/scripts/monitor.sh

OpenClaw Heartbeat集成

HEARTBEAT.md 中添加:

### 电商竞对监控 (09:00)
- [ ] 执行竞品数据采集
- [ ] 分析价格销量变化
- [ ] 生成监控日报
- [ ] 推送到飞书群

数据存储

数据结构

{
  "monitoring_data": [
    {
      "product_id": "商品ID",
      "platform": "taobao/jd",
      "product_name": "产品名称",
      "current_price": 129.00,
      "previous_price": 139.00,
      "sales_count": "5000+",
      "rating_score": 4.8,
      "review_count": 1250,
      "monitor_time": "2026-03-26 09:00:00",
      "price_change": -10.00,
      "change_percent": -7.19
    }
  ]
}

数据持久化

# scripts/data-manager.py
import json
import os

class DataManager:
    def __init__(self, data_file="data/monitoring.json"):
        self.data_file = data_file
        os.makedirs(os.path.dirname(data_file), exist_ok=True)
    
    def save_data(self, data):
        """保存监控数据"""
        existing_data = self.load_data()
        existing_data['monitoring_data'].append(data)
        
        with open(self.data_file, 'w', encoding='utf-8') as f:
            json.dump(existing_data, f, ensure_ascii=False, indent=2)
    
    def load_data(self):
        """加载历史数据"""
        if os.path.exists(self.data_file):
            with open(self.data_file, 'r', encoding='utf-8') as f:
                return json.load(f)
        else:
            return {'monitoring_data': []}

脚本工具

monitor.sh - 主监控脚本

#!/bin/bash
# scripts/monitor.sh

set -e

# 设置环境
cd "$(dirname "$0")/.."

# 执行数据采集
python scripts/fetch-taobao.py
python scripts/fetch-jd.py

# 数据分析
python scripts/analyze-data.py

# 生成日报
python scripts/generate-report.py

# 推送飞书
python scripts/send-to-feishu.py

echo "监控任务完成: $(date)"

fetch-taobao.py - 淘宝数据采集

# scripts/fetch-taobao.py
import json
from datetime import datetime

def fetch_taobao_data(product_url):
    """采集淘宝商品数据"""
    # 使用agent-browser访问页面
    # 提取价格、销量、评价等信息
    
    data = {
        "platform": "taobao",
        "product_url": product_url,
        "price": extract_price(),
        "sales": extract_sales(),
        "rating": extract_rating(),
        "timestamp": datetime.now().isoformat()
    }
    
    return data

analyze-data.py - 数据分析

# scripts/analyze-data.py
import json
from data_manager import DataManager

def analyze_trends():
    """分析价格销量趋势"""
    dm = DataManager()
    data = dm.load_data()
    
    # 价格变化分析
    recent_prices = [d['current_price'] for d in data['monitoring_data'][-7:]]
    price_trend = 'stable'
    if len(recent_prices) >= 2:
        if recent_prices[-1] > recent_prices[0]:
            price_trend = 'up'
        elif recent_prices[-1] < recent_prices[0]:
            price_trend = 'down'
    
    return {
        'price_trend': price_trend,
        'avg_price': sum(recent_prices) / len(recent_prices) if recent_prices else 0
    }

配置管理

监控配置示例

# config/monitoring-config.yaml
monitoring:
  targets:
    - name: "竞品A"
      platform: "taobao"
      url: "https://item.taobao.com/item.htm?id=xxx"
      enabled: true
    - name: "竞品B" 
      platform: "jd"
      url: "https://item.jd.com/xxx.html"
      enabled: true
  
  schedule:
    frequency: "daily"
    time: "09:00"
    
  feishu:
    enabled: true
    group_id: "飞书群ID"
    
  data_retention:
    days: 30

环境变量配置

# .env
TAOBAO_MONITOR_ENABLED=true
JD_MONITOR_ENABLED=true
FEISHU_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/xxx
DATA_RETENTION_DAYS=30

故障处理

常见问题解决

问题原因解决方案
页面无法访问反爬虫机制使用代理IP,添加随机延迟
数据提取失败页面结构变化更新选择器,添加备用方案
飞书推送失败网络问题/权限检查网络,验证webhook权限
数据存储异常文件权限/空间检查磁盘空间,文件权限

监控状态检查

# 检查监控状态
./scripts/status-check.sh

# 查看最近监控记录
cat data/monitoring.json | jq '.monitoring_data[-5:]'

# 测试飞书推送
./scripts/feishu-test.sh "测试消息"

最佳实践

监控策略

  1. 选择合适的监控频率

    • 高价值竞品:每小时监控
    • 一般竞品:每天监控
    • 低频变化:每周监控
  2. 数据质量控制

    • 设置数据验证规则
    • 异常数据自动标记
    • 定期数据备份
  3. 告警机制

    • 价格大幅波动告警
    • 销量异常增长告警
    • 监控失败告警

性能优化

# 异步数据采集
import asyncio

async def fetch_multiple_products(product_urls):
    """异步采集多个商品数据"""
    tasks = [fetch_product_data(url) for url in product_urls]
    results = await asyncio.gather(*tasks, return_exceptions=True)
    return results

扩展功能

多平台支持

  • 拼多多监控
  • 天猫监控
  • 亚马逊监控
  • 抖音电商监控

高级分析

  • 价格预测模型
  • 竞品画像分析
  • 市场趋势预测
  • 自动化报告生成

许可证

许可证: MIT — 可自由使用、修改、分发


"数据驱动的决策是电商竞争的核心优势"