有些优惠或通知,手动查看网页太麻烦容易漏过,想起来用软件自动监控一下。部署在服务器上,一有更新就可以通过Telegram提醒了。

首先是安装软件,系统是Ubuntu20.04 LTS。

apt update 
apt install urlwatch

输入

urlwatch --edit

注释掉不需要的组和行,添加自己想监控的网页url,格式参照配置实例

name,filterurl是一一配对的,建议使用此格式

name: A web page
url: "https://www.example.com"
filter: html2text,strip

之后去Telegram申请一个Bot

Telegram搜索BotFather,点开之后按/start

出现一段信息,点/newbot

给你的bot起个名字,要以_bot或者bot结尾

如果没有重名的话,会得到一段

Done! Congratulations on your new bot. You will find it at t.me/xxxBot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.

Use this token to access the HTTP API:
**999999999:3tOhy2CuZE0pTaCtszRfKpnagOG8IQbP5gf **

Keep your token secure and store it safely, it can be used by anyone to control your bot.For a description of the Bot API, see this page: https://core.telegram.org/bots/api

点进自己的bot链接,点/start,然后发一个hello或者其他信息

复制粗体的部分

然后在服务器上运行

urlwatch --edit-config

找到telegram字段,添加bot_token,保存退出

telegram:
  bot_token: '999999999:3tOhy2CuZE0pTaCtszRfKpnagOG8IQbP5gf'

运行urlwatch –telegram-chats,可以得到chat id

然后在配置添加字段

telegram:
  bot_token: '999999999:3tOhy2CuZE0pTaCtszRfKpnagOG8IQbP5gf'
  chat_id: '999999999'

配置完成。你可以新添加一条URL来测试通知是否能送达。

之后每次运行urlwatch都会进行检查,所以可以按情况需求配置cron或者systemd timer定时运行。