Last active
December 16, 2020 16:42
-
-
Save mtellin/54d6bdfeb4596360305828dcf0226ab0 to your computer and use it in GitHub Desktop.
My most pathetic script yet. Checks local Culver's for the Flavor of the Day ice cream and sends a message to Slack when it is Bonfire S'mores.
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
#!/usr/bin/env python3 | |
# Script to check Culver's and alert when it's bonfire smores | |
import requests | |
import os | |
from bs4 import BeautifulSoup | |
# Set environment variables for the following items | |
slackToken = os.environ['SLACK_TOKEN'] | |
culversLogo = os.environ['CULVERS_LOGO'] | |
city = os.environ['CULVERS_CITY'] | |
# Pull the local Culver's page and use BeautifulSoup to parse | |
page = requests.get(f'https://www.culvers.com/restaurants/{city}') | |
soup = BeautifulSoup(page.text, 'html.parser') | |
fotdSection = soup.find("div", {"class": "ModuleRestaurantDetail-fotd"}) | |
fotdString = fotdSection.text | |
fotd = fotdString.split('Day: ')[1] | |
# Using rstrip to remove the extra line break so I can compare the strings | |
if fotd.rstrip() == 'Bonfire S\'mores': | |
slackData = { | |
'channel': '#general', | |
'text': 'The flavor of the day is Bonfire S\'mores', | |
'username': 'culvers', | |
'icon_url': culversLogo, | |
'token': slackToken | |
} | |
response = requests.post('https://slack.com/api/chat.postMessage', slackData) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi friend, I was curious if Culver's had an API for flavors of the day and found this -- I just want to let you know that there is nothing pathetic about this script. 🍨