Last active
May 6, 2021 12:19
-
-
Save thomasjungblut/8cc5465882ffe92716adda385f841584 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python3 | |
from time import sleep | |
import requests | |
from twilio.rest import Client | |
TWILIO_ACCOUNT_SID = "ACXXX" | |
TWILIO_AUTH_TOKEN = "XXX" | |
FROM = "+1XXXXX" | |
RECIPIENT = "+491XXXX" | |
def send_message(body: str): | |
print(body) | |
client = Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) | |
message = client.messages.create(to=RECIPIENT, from_=FROM, body=body) | |
print("message sent: {}" % message.sid) | |
while True: | |
response = requests.get('https://www.doctolib.de/booking/ciz-berlin-berlin.json') | |
if response: | |
body = response.json() | |
practises = dict( | |
map(lambda place: (place['practice_ids'][0], (place['id'], place['formal_name'])), body['data']['places'])) | |
agendas = body['data']['agendas'] | |
for agenda in agendas: | |
if not agenda['booking_disabled']: | |
practise = practises[agenda['practice_id']] | |
send_message( | |
"available vacc at %s go to https://www.doctolib.de/institut/berlin/ciz-berlin-berlin?pid=%s" % ( | |
practise[1], practise[0])) | |
else: | |
print("error while querying for data") | |
sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment