Last active
May 1, 2019 16:19
-
-
Save peterc/be144343f59b33882b8268d4cef07058 to your computer and use it in GitHub Desktop.
Watch a Web page for changes and show the differences
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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