Created
May 24, 2021 10:00
-
-
Save malys/90fea8d48e709b26a3cfaa0534913756 to your computer and use it in GitHub Desktop.
Vaccination
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
import requests | |
import json | |
import time | |
import datetime | |
proxies={ | |
} | |
searches=[ | |
{"toulouse-31000":"vaccinodrome-toulouse"}, | |
{"balma-31130":"balma"}, | |
{"villefranche-de-lauragais-31290":"clinique-monie-villefranche-de-lauragais"}, | |
{"toulouse-31059":"centre-hospitalier-universitaire-toulouse-site-purpan"}, | |
{"toulouse-31000":"toulouse-bourbaki"}, | |
{"ramonville-saint-agne-31520":"centre-de-vaccination-ramonville-saint-agne"}, | |
{"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"] or "Pfizer" in motive["name"] or "Moderna" in motive["name"]) and not "Mono" 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=20) | |
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("\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