Schlagwort-Archive: website

How to monitor any website. At any time interval. With Telegram notification. For Free.

These instructions work for OSX Catalina only and are a bit different than the Linux version shown at urlwatch.

python3 -m pip install pyyaml minidb requests keyring appdirs lxml cssselect html2text
python3 -m pip install urlwatch
EDITOR=nano
urlwatch --edit
# CTRL+X leave the editor without saving

Then edit ~/Library/Application Support/urlwatch/urls.yaml

kind: url
max_tries: 3
name: Camptoi
url: https://www.camptoi.de
filter:
- element-by-id: product-desc-18713727425
- html2text:
    body_width: 0
    ignore_images: false
    ignore_links: false
    inline_links: false
    method: pyhtml2text
    pad_tables: false
    single_line_break: true
    unicode_snob: true

After that we create the Telegram bot by sending

/newbot

to user BotFather and record the <API> from the response.

We also need to send a dummy message to the new bot so we can look up the sender <ID>

https://api.telegram.org/bot<API>/getUpdates

<API> and <ID> are both entered into ~/Library/Application Support/urlwatch/urlwatch.yaml

...
  telegram:
    bot_token: '<API>'
    chat_id: '<ID>'
    enabled: true
---

As we have no cron under MacOS we need a parameter file to run launchd. Should be placed at ~/Library/LaunchAgents/com.urlwatch.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
	<dict>
		<key>Label</key>
		<string>com.urlwatch</string>
		<key>Program</key>
		<string>/Users/wjst/opt/anaconda3/bin/urlwatch</string>
		<key>RunAtLoad</key>
        <true/>
        <key>StartInterval</key>
        <integer>9000</integer>
        <key>KeepAlive</key>
         <true/>       
	</dict>
</plist>

Ultimately, the agent is started (or stopped) using

launchctl load ~/Library/LaunchAgents/com.urlwatch.plist               
launchctl unload ~/Library/LaunchAgents/com.urlwatch.plist

Link out symbol

I have been looking for a wikipedia-style link out symbol (wikipedia uses a svg symbol). Some websites recommend font awesome symbol /f08e others are in favor of the north east arrow #x2197; while I modfied now a code pen by thiago for the css of this wordpress child theme

  a:not([href*='wjst.de'])::after {
    content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAQElEQVR42qXKwQkAIAxDUUdxtO6/RBQkQZvSi8I/pL4BoGw/XPkh4XigPmsUgh0626AjRsgxHTkUThsG2T/sIlzdTsp52kSS1wAAAABJRU5ErkJggg==);
    margin: 0 3px 0 5px;
  }