使用 Playwright 实时监听虚拟货币新闻网站,检测新文章发布并自动抓取全文、AI 总结、推送 Telegram。
完全开源透明 · 源码 + 运行截图: https://github.com/vvxer/openclaw-news-watcher
变量必填说明OPENCLAW_MJS✅ 必填openclaw.mjs 的完整路径,用于调用 AI Agent 和发送消息TELEGRAM_USER_ID✅ 必填Telegram 收件人 Chat IDCHROME_PATH可选本地 Chrome 路径;未设置时按平台自动检测PLAYWRIGHT_HEADLESS可选设为 false 显示浏览器窗口(调试用),默认 truebash
# Windows PowerShell
$env:OPENCLAW_MJS = "D:\openclaw\node_modules\openclaw\openclaw.mjs"
$env:TELEGRAM_USER_ID = "你的ChatID"
# Linux / macOS
export OPENCLAW_MJS="/path/to/openclaw.mjs"
export TELEGRAM_USER_ID="你的ChatID"
bash
node {baseDir}/scripts/watch-news.js
bash
node {baseDir}/scripts/watch-news.js --site panews
node {baseDir}/scripts/watch-news.js --site coindesk --interval 120
--site <name> - 网站名称(支持: coindesk, panews)--interval <seconds> - 检查间隔(秒),默认 60openclaw agent 生成中文摘要openclaw message send 发送到 Telegram新闻哈希缓存存储在: ~/.openclaw/cache/news-hash.json
bash
node ~/.openclaw/workspace/skills/news-watcher/scripts/watch-news.js --site coindesk --interval 60
bash
openclaw agent --message "监听 CoinDesk 新闻,有更新就通知我" --timeout 600
bash
openclaw cron add \
--name "Morning News Digest" \
--cron "0 7 * * *" \
--tz "Asia/Shanghai" \
--session isolated \
--message "总结过去一晚上的加密新闻,列出前 3 个重点" \
--announce \
--channel telegram \
--to "$TELEGRAM_USER_ID"
网站site 参数说明CoinDeskcoindesk全球权威加密新闻PANewspanews中文区块链新闻
编辑 watch-news.js,在 sites 对象中添加:
javascript
const sites = {
coindesk: { /* ... */ },
mynews: {
url: 'https://example.com/news',
selector: '.article-item',
getContent: () => { /* 可选自定义提取逻辑 */ }
}
};
bash
export OPENCLAW_MJS="/path/to/openclaw.mjs"
bash
export TELEGRAM_USER_ID="你的Telegram Chat ID"
bash
node {baseDir}/scripts/watch-news.js --interval 180
bash
PLAYWRIGHT_HEADLESS=false node {baseDir}/scripts/watch-news.js
bash
export CHROME_PATH="/usr/bin/google-chrome" # Linux
export CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" # macOS