Last active
May 10, 2024 14:33
-
-
Save hacktivist123/fd0ce12d92aeb763ccc906a094f688e0 to your computer and use it in GitHub Desktop.
scrapes a site and sends a notification
This file contains hidden or 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 | |
# Configuration | |
URL="https://cilium.slack.com/join/shared_invite/zt-2i32e3vq8-wZwHT3v2RCI0YNDiqkIK3g" | |
EXPECTED_TITLE="Join Cilium & eBPF on Slack | Slack" | |
LOG_FILE="$HOME/Developer/Isovalent/check_slack/website_check_log.txt" | |
USER_AGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" | |
ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" | |
ACCEPT_LANGUAGE="en-US,en;q=0.9" | |
# Fetch the title from the URL using curl and sed | |
TITLE=$(curl -sL \ | |
-H "User-Agent: $USER_AGENT" \ | |
-H "Accept: $ACCEPT" \ | |
-H "Accept-Language: $ACCEPT_LANGUAGE" \ | |
"$URL" | sed -n 's/.*<title>\(.*\)<\/title>.*/\1/p') | |
# Check if the fetched title matches the expected title | |
if [ "$TITLE" == "$EXPECTED_TITLE" ]; then | |
# Send a local notification if the title matches | |
osascript -e 'display notification "The site title matches the expected title." with title "Cilium Slack Check"' | |
echo "$(date): Success - The site title matches the expected title." >> $LOG_FILE | |
else | |
# Send a local notification if the title does not match | |
osascript -e 'display notification "The site title does not match the expected title." with title "Cilium Slack Check"' | |
echo "$(date): Error - The site title does not match. Found: $TITLE" >> $LOG_FILE | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment