#!/bin/sh URL="$1" SELECTORS="$2" if ! command -v pup >/dev/null 2>&1; then printf "Can not find dependency: pup\n" exit 1 fi if ! command -v curl >/dev/null 2>&1; then printf "Can not find dependency: curl\n" exit 1 fi if test -z "$URL" || test -z "$SELECTORS"; then printf "$0 \n" exit 1 fi VERSION1="$(mktemp)" VERSION2="$(mktemp)" curl -s "$URL" | pup "$SELECTORS" > "$VERSION1" while true; do sleep "${SLEEP:-60}" curl -s "$URL" | pup "$SELECTORS" > "$VERSION2" DIFF="$(diff "$VERSION1" "$VERSION2")" if test $? -ne 0; then printf "Change detected $(date)\n" printf "$DIFF\n\n" fi cat "$VERSION2" > "$VERSION1" done