-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcowin.txt
55 lines (43 loc) · 1.77 KB
/
cowin.txt
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
import requests
import json
from datetime import datetime
import easygui
import webbrowser
import time
import sys
ProdUrl = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByDistrict?"
headers = {'Accept': 'application/json',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36'
}
district_id = "392"
CheckAfter = 1
VaccineType = "COVISHIELD"
MyAge = 24
def SlotChecker():
x = datetime.now()
Day = '30'
Month = str(x.month)
Year = str(x.year)
FetchUrl = ProdUrl + "district_id=" + district_id + "&date=" + Day + "-" + Month + "-" + Year
ApiResponse = requests.get(FetchUrl, headers = headers)
response_json = ApiResponse.json()
data = response_json['sessions']
print(Day)
counter = 0
for s in data:
if (MyAge >= s['min_age_limit'] and s['vaccine'] == VaccineType.upper()) and (s['available_capacity'] > 0):
counter += 1
MsgText = "We have found an availability at "+ s['name'] + " for age " + str(s['min_age_limit']) + "+ and vaccine type "+ s['vaccine'] + ". Current available capacity is " + str(s['available_capacity']) + " Do you want to book now ?"
UserInput = easygui.ynbox(MsgText, 'Cowin Slot Finder (Author: Rajan Shah)', ('Yes', 'No'))
if(UserInput):
webbrowser.open("https://www.cowin.gov.in/home")
sys.exit()
sys.exit()
if counter == 0:
print("slot not found")
return True
while(True):
SlotChecker()
print("Last checked at %s " % (str(datetime.now().time()),))
print("We'll check again in %s minute(s)" % (CheckAfter,))
time.sleep(CheckAfter*60)