Created
August 28, 2018 19:32
-
-
Save szepeviktor/962dd324f63ffa6df51c0040f158f99a to your computer and use it in GitHub Desktop.
Slack üzenetet küld, ha egy új étteremnek van Boldog Órája a Netpincéren
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 | |
# | |
# Send notification on new Netpincér Boldog Óra restaurants. | |
# | |
# DEPENDS :pip3 install slack-webhook-cli | |
# Boldog Óra page | |
NETPINCER_BOLDOGORA="https://www.netpincer.hu/budapest_iii/hazhozszallitas/happy/1" | |
# Cache file | |
NETPINCER_BOLDOGORA_CACHE="${HOME}/.cache/netpincer-boldogora" | |
# Slack webhook | |
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/GET-A-Slack-WEBHOOK-URL-FOR-YOURSELF" | |
# User name | |
export SLACK_USERNAME="NetpincérMOST" | |
# User icon URL | |
export SLACK_ICON_URL="https://www.netpincer.hu/apple-touch-icon.png" | |
Restaurants() | |
{ | |
# Fetch HTML | |
# Parse names | |
# Exclude some | |
# Join lines | |
wget -q -O- "$NETPINCER_BOLDOGORA" \ | |
| sed -n -e 's#.*itemprop="name">\([^<]\+\)<.*#\1#p' \ | |
| grep -E -x -v '(Nemo Fish & Chips & Salad Házhozszállítás|Theo Papa Konyhája)' \ | |
| paste -s -d "," | |
} | |
# Store current list | |
CURRENT="$(Restaurants)" | |
# If cached and current differ | |
if ! diff -q "$NETPINCER_BOLDOGORA_CACHE" <(echo "$CURRENT") >/dev/null; then | |
# Update cache | |
echo "$CURRENT" >"$NETPINCER_BOLDOGORA_CACHE" | |
# Send notification if not empty | |
if [ -n "$CURRENT" ]; then | |
~/.local/bin/slack "$CURRENT" | |
fi | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment