Ecommerce Price Watcher
Monitor product URLs, keep price history, detect offers, and output alert-ready JSON.
Quick start
Use scripts/price_watch.py.
CODEBLOCK0
Commands
- -
add: add a single product URL - INLINECODE2 : discover product URLs from an item query, then add watches
- INLINECODE3 : list watched products
- INLINECODE4 : check one product now
- INLINECODE5 : check all products now
- INLINECODE6 : delete watcher
- INLINECODE7 : print full price history
Alert behavior
A check produces alerts when at least one condition matches:
- 1.
price_drop: current price < previous price - INLINECODE9 : current price <= target price
Alert payload includes:
- - product id
- title
- old/new price
- drop percent (when available)
- URL
- timestamp
Item-query mode details
INLINECODE10 uses a lightweight search discovery flow to find candidate product links.
- -
--trusted-only restricts discovered URLs to a curated trusted domain list. - INLINECODE12 controls how many links are added.
- Duplicate URLs are skipped safely.
This gives users natural language entry ("track iPhone 13 128GB") instead of forcing direct URLs.
Parsing strategy
Use a layered parser:
- 1. JSON-LD INLINECODE13
- Open Graph/meta price fields
- Generic HTML regex fallback
When multiple prices are found, choose the lowest positive value as the current offer candidate.
Security standards
- - Accept only
http/https URLs. - Enforce request timeout.
- Enforce response body size cap.
- Do not execute remote JavaScript.
- Store no API keys/tokens in watcher data.
- Treat all page content as untrusted.
- Return structured JSON for safe downstream automation.
Limits and operational notes
- - Some stores block bot-like requests (403). This is expected on certain sites.
- Price extraction is best-effort and may need store-specific adapters over time.
- For production alerting, run
check --all on schedule and forward only non-empty alerts.
Suggested scheduled usage
Run every 30–120 minutes via cron, then send each alert to Telegram/WhatsApp/Discord.
电商价格监控器
监控产品URL,记录价格历史,检测优惠信息,并输出可触发警报的JSON格式数据。
快速开始
使用 scripts/price_watch.py 脚本。
bash
URL模式
python3 skills/ecommerce-price-watcher/scripts/price_watch.py add \
--url https://example.com/product \
--target-price 399990 \
--currency CLP
商品模式(通过查询发现URL)
python3 skills/ecommerce-price-watcher/scripts/price_watch.py add-item \
--query iPhone 13 128GB Chile \
--target-price 349990 \
--currency CLP \
--trusted-only \
--max-results 5
python3 skills/ecommerce-price-watcher/scripts/price_watch.py check --all
命令说明
- - add:添加单个产品URL
- add-item:通过商品查询发现产品URL,然后添加监控
- list:列出所有被监控的产品
- check --id :立即检查指定产品
- check --all:立即检查所有产品
- remove --id :删除监控器
- history --id :打印完整价格历史
警报触发机制
当满足以下至少一个条件时,检查操作会触发警报:
- 1. pricedrop:当前价格 < 上次价格
- targethit:当前价格 <= 目标价格
警报数据包包含:
- - 产品ID
- 标题
- 旧价/新价
- 降价百分比(如有)
- URL
- 时间戳
商品查询模式详解
add-item 使用轻量级搜索发现流程来查找候选产品链接。
- - --trusted-only 将发现的URL限制在可信域名列表中。
- --max-results 控制添加的链接数量。
- 重复URL会被安全跳过。
这允许用户使用自然语言输入(如追踪iPhone 13 128GB),而无需直接提供URL。
解析策略
采用分层解析器:
- 1. JSON-LD offers.price
- Open Graph/元数据价格字段
- 通用HTML正则表达式回退
当发现多个价格时,选择最低的正值作为当前优惠候选价格。
安全标准
- - 仅接受 http/https URL。
- 强制设置请求超时。
- 强制限制响应体大小。
- 不执行远程JavaScript。
- 不在监控数据中存储API密钥/令牌。
- 将所有页面内容视为不可信数据。
- 返回结构化JSON,确保下游自动化安全。
限制与操作说明
- - 部分商店会阻止类似爬虫的请求(返回403)。这在某些网站上是预期行为。
- 价格提取采用尽力而为原则,可能需要针对特定商店开发适配器。
- 对于生产环境的警报系统,建议定时运行 check --all,仅转发非空的 alerts。
建议的定时使用方案
通过cron每30-120分钟运行一次,然后将每条警报发送到Telegram/WhatsApp/Discord。