Skip to content

Instantly share code, notes, and snippets.

@peterc
Last active May 1, 2019 16:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterc/be144343f59b33882b8268d4cef07058 to your computer and use it in GitHub Desktop.
Save peterc/be144343f59b33882b8268d4cef07058 to your computer and use it in GitHub Desktop.
Watch a Web page for changes and show the differences
#!/bin/bash
# usage:
# chmod +x watch_page
# ./watch_page
while [ 1 ]
do
if [ -e /tmp/latest.html ]; then
cp /tmp/latest.html /tmp/previous.html
else
touch /tmp/previous.html
fi
curl -s https://www.drudgereport.com/ > /tmp/latest.html
new=`shasum /tmp/latest.html | awk '{ print $1 }'`
old=`shasum /tmp/previous.html | awk '{ print $1 }'`
if [ "$new" != "$old" ]; then
echo "Page has changed:"
diff /tmp/previous.html /tmp/latest.html
echo "----------------------"
else
echo "Page has not updated"
fi
echo "Sleeping.. ctrl+c to quit, enter to retry"
read -t 120
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment