Monitoring websites for changes from the CLI
Last updated:
The watch
command allows us to poll text-based resources, the content is rendered to the CLI and any changes between the polls detected are highlighted.
Check a remote resource for changes
This applies simple text-based to feeds
watch -n 10 -d -b curl -s https://[feed-provider]/feed
Check a website for changes
Using curl
on Websites will typically return strings that are too long to show properly in the terminal. Instead we can use the text-based Lynx browser that manages to render quite a few websites sufficiently well.
To install on MacOS do
brew install lynx
We may need to add a line to the “character set” section of the Lynx config:
CHARACTER_SET:utf-8
then we watch:
watch -n 10 -d "lynx -dump -nolist https://[some-host]/incidents/01d59b"
Notifications
If the “live” highlighting is not enough we could use the --chgexit
option which will exit the watch
command when a change is detected. With this we can run it in a loop with another command that could send a notification, make a sound or trigger some kind of other automation.