-
Notifications
You must be signed in to change notification settings - Fork 6
/
vaccine.py
71 lines (57 loc) · 2.28 KB
/
vaccine.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import requests
import datetime
import json
import pandas as pd
import smtplib
for state_code in range(1,40):
print("State code: ", state_code)
response = requests.get("https://cdn-api.co-vin.in/api/v2/admin/location/districts/{}".format(state_code))
json_data = json.loads(response.text)
for i in json_data["districts"]:
print(i["district_id"],'\t', i["district_name"])
print("\n")
DIST_ID = 446
# Print available centre description (y/n)?
print_flag = 'y'
numdays = 20
age = 19
base = datetime.datetime.today()
date_list = [base + datetime.timedelta(days=x) for x in range(numdays)]
date_str = [x.strftime("%d-%m-%Y") for x in date_list]
for INP_DATE in date_str:
URL = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id={}&date={}".format(DIST_ID, INP_DATE)
response = requests.get(URL)
if response.ok:
resp_json = response.json()
# print(json.dumps(resp_json, indent = 2))
if resp_json["centers"]:
print("Available on: {}".format(INP_DATE))
if(print_flag=='y' or print_flag=='Y'):
for center in resp_json["centers"]:
for session in center["sessions"]:
if session["min_age_limit"] <= age:
print("\t", center["name"])
print("\t", center["block_name"])
print("\t Price: ", center["fee_type"])
print("\t Available Capacity: ", session["available_capacity"])
if(session["vaccine"] != ''):
print("\t Vaccine: ", session["vaccine"])
print("\n\n")
else:
print("No available slots on {}".format(INP_DATE))
def send_mail(self):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.ehlo()
server.login('[email protected]', 'machinelearning@#$000')
subject = 'VACCINE NOTIFICATION'
body = 'XXX'
msg = f"Subject: {subject}\n\n{body}"
server.sendmail(
'Coronavirus',
msg
)
print('Email has been sent !')
server.quit()