Created
June 23, 2017 14:45
-
-
Save joac/dd17ada3fdc5f960fbb3c6b1d1128de2 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
import requests | |
import time | |
import telegram_send | |
import datetime | |
from collections import defaultdict | |
telegram_send.send(['Starting bot']) | |
known_data = defaultdict(list) | |
while True: | |
turnos = [] | |
date = datetime.date.today() | |
response = requests.get("https://formulario-sigeci.buenosaires.gob.ar/FechasDisp?fromDate={:%Y-%m-%d}&servicioId=1342".format(date)) | |
print(response) | |
data = response.json() | |
if data != []: | |
for sede in data: | |
sede_id = sede['sede']['id'] | |
for fecha in sede['fechas']: | |
if fecha not in known_data[sede_id]: | |
turnos.append("{} en {}".format(fecha, sede['sede']['nombre'])) | |
known_data[sede_id].append(fecha) | |
if turnos: | |
telegram_send.send(['Hay turnos!']) | |
telegram_send.send(turnos) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment