by Jason Snell - [email protected]
This Python script scrapes upcoming items from Google Calendar HTML and posts them to Slack.
The result looks kind of like this:
You'll need a Google Calendar HTML embed URL.
To get it, go to your Google Calendar, click on the options menu next to the calendar in the sidebar.
- Choose 'Settings and sharing.'
- Scroll down to 'Integrate calendar' and grab the Embed code HTML.
- Embedded within the 'src' tag will be a URL. This is what you want.
- Change the '/embed?' string to 'htmlembed?'
- Add 'mode=AGENDA' to the end
- Change the string following 'ctz' to be UTC
- Paste the result into the url variable below
It should look something like:
https://calendar.google.com/calendar/u/0/htmlembed?src=yourdomain.com_biglonggarbagestring99@group.calendar.google.com&ctz=UTC&mode=AGENDA
You'll need to create a Slack app and install it in your Slack and point it at a particular channel in order to get a webhook URL for userin the script.
For more info, read how to do this from Slack itself.
That's it! This will work until Google changes the HTML of its Agenda embed, which to be honest looks like it hasn't changed in decades.