Last active
May 19, 2021 13:44
-
-
Save polymorf/5a9752f2ccf70dfc8034928ab03dfeff to your computer and use it in GitHub Desktop.
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 | |
# coding: utf8 | |
from polytools import * | |
import requests | |
import json | |
import time | |
import datetime | |
proxies={ | |
} | |
searches=[ | |
{"labarthe-sur-leze-31860":"labarthe-sur-leze"}, | |
{"toulouse-31000":"vaccinodrome-toulouse"}, | |
{"balma-31130":"balma"}, | |
{"villefranche-de-lauragais-31290":"clinique-monie-villefranche-de-lauragais"}, | |
{"montrejeau-31210":"montrejeau"}, | |
{"toulouse-31059":"centre-hospitalier-universitaire-toulouse-site-purpan"}, | |
{"toulouse-31000":"toulouse-bourbaki"}, | |
{"auterive-31190":"auterive"}, | |
{"ramonville-saint-agne-31520":"centre-de-vaccination-ramonville-saint-agne"}, | |
{"muret-31600":"muret-salle-horizon"}, | |
{"toulouse-31000":"toulouse-niel"}, | |
{"st-orens-de-gameville-31650":"saint-orens-de-gameville"}, | |
{"castanet-tolosan-31320":"castanet-tolosan"}, | |
{"toulouse-31059":"centre-hospitalier-universitaire-toulouse-larrey"}, | |
] | |
s = requests.Session() | |
s.proxies=proxies | |
for search in searches: | |
for loc in search.keys(): | |
url="https://booking.keldoc.com/api/patients/v2/searches/resource?type=cabinet-medical&location=%s&slug=%s" % (loc, search[loc]) | |
r = s.get(url) | |
j = json.loads(r.text) | |
centre_id = j["id"] | |
url="https://booking.keldoc.com/api/patients/v2/clinics/%d/specialties/144/cabinets" % (centre_id) | |
r = s.get(url) | |
j = json.loads(r.text) | |
for obj in j: | |
centre_id_2 = obj["id"] | |
centre_name = obj["name"] | |
print(centre_name) | |
url="https://booking.keldoc.com/api/patients/v2/clinics/%d/specialties/144/cabinets/%d/motive_categories" % (centre_id, centre_id_2) | |
r = s.get(url) | |
j = json.loads(r.text) | |
for entry in j: | |
for motive in entry["motives"]: | |
if "+18" in motive["name"]: | |
print("\tchecking : %s" % (motive["name"])) | |
resa_id = motive["id"] | |
agendas = [] | |
for a in motive["agendas"]: | |
agendas.append(a["id"]) | |
url="https://booking.keldoc.com/api/patients/v2/timetables/%d" % resa_id | |
today = datetime.date.today() | |
end_date= today + datetime.timedelta(days=2) | |
from_date = today.strftime("%Y-%m-%d") | |
to_date = end_date.strftime("%Y-%m-%d") | |
params={ | |
"from":from_date, | |
"to":to_date, | |
"agenda_ids[]":agendas | |
} | |
r = s.get(url, params=params) | |
j = json.loads(r.text) | |
alert=False | |
if "availabilities" in j.keys(): | |
for entry in j["availabilities"].keys(): | |
if len(j["availabilities"][entry]) > 0: | |
alert=True | |
if alert: | |
print_obj(j) | |
print("\033[32;1mPlaces pour %s\033[0m" % (motive["name"])) | |
print("https://vaccination-covid.keldoc.com/redirect/?dom=cabinet-medical&inst=%s&user=%s" % (loc, search[loc])) | |
os.system('notify-send -u critical -t 10000000 "%s" "%s"' % (search[loc], motive["name"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment