Skip to content

Instantly share code, notes, and snippets.

@novotnyr
Last active July 30, 2017 18:41
Show Gist options
  • Save novotnyr/088b375e4461192829e27bf27665783e to your computer and use it in GitHub Desktop.
Save novotnyr/088b375e4461192829e27bf27665783e to your computer and use it in GitHub Desktop.
Downloads a lunch menu from KeltskaKrcma.sk and pipes it to the Slack webhook.
#!/bin/sh
SLACK_HOOK=___FILL_IN____
curl -s http://keltskakrcma.sk/index.php \
| hxnormalize -x \
| hxunent \
| hxselect -i "#left_galeria table:nth-child(11)" \
| hxnormalize -x -i 2 -l 99999 \
| xmlstarlet sel -t -v "//tr[position() > 1]/td//text()" \
| grep -ve '^\s*$' \
| paste -d ' ' - - \
| jq -R -s '{"attachments": [{"color": "#36a64f", "title": "Keltská krčma - denné menu", "title_link": "http://keltskakrcma.sk/index.php", "text": . } ] }' \
| curl -X POST -H 'Content-type: application/json' --data @- https://hooks.slack.com/services/${SLACK_HOOK
@novotnyr
Copy link
Author

Requirements

  • html-xml-utils
  • gnu-sed (to support Unicode on MacOS)
  • xmlstarlet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment