Costinel: 您的 VPS 补货监控哨兵,助您第一时间抢占高性价比主机。
一个基于 Node.js 和 Puppeteer 的专业 VPS 库存监控工具,采用标准化架构设计,易于维护和扩展。
- 🎯 精准监控:基于 Puppeteer 实现真实浏览器模拟
- 🔔 及时通知:支持 Telegram 通知
- 🔧 易于扩展:支持添加新的供应商和通知渠道
git clone https://github.com/harrisonwang/costinel.git
cd costinel# 安装 xvfb
apt install -y xvfb
# 安装 chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
apt install -y ./google-chrome-stable_current_amd64.deb
# 安装依赖
npm i在项目根目录创建 .env 文件:
# Telegram 配置
TELEGRAM_BOT_TOKEN=你的bot_token
TELEGRAM_CHAT_ID=你的chat_idnpm start # 正常启动
npm run dev # 开发模式
npm run debug # 调试模式编辑 src/config/products.config.js:
export const PRODUCTS = [
{
name: '产品名称',
url: '产品链接',
site: '站点域名',
description: '产品描述'
}
];编辑 src/config/sites.config.js:
export const SITE_CONFIGS = {
'站点域名': {
stockSelector: 'CSS选择器',
outOfStockText: '缺货文本',
waitTime: 3000 // 页面等待时间(毫秒)
}
};- 在 Telegram 中联系 @BotFather
- 使用
/newbot命令创建机器人 - 保存获得的 Bot Token
- 向您的机器人发送任意消息
- 访问:
https://api.telegram.org/bot<YourBOTToken>/getUpdates - 在响应中找到
chat.id字段
使用 crontab 实现定时检查:
# 编辑 crontab
crontab -e
# 每5分钟检查一次
*/5 * * * * /opt/projects/costinel/scripts/costinel.sh
# 或使用 npm start
*/5 * * * * cd /opt/projects/costinel && npm start >> logs/costinel.log 2>&1欢迎提交 Pull Request 或 Issue!
小王爷