Last active
May 3, 2021 08:56
-
-
Save AvinashDalvi89/a01eb8661095b690fb1caa95267c31c6 to your computer and use it in GitHub Desktop.
track cowin vacinnation
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 json | |
import os | |
import time | |
import datetime | |
print("Which search you would like to do ? 1. Pincode 2. State code") | |
choice = input() | |
currtime = datetime.datetime.now() | |
date = currtime.strftime("%d")+"-"+currtime.strftime("%m")+"-"+currtime.strftime("%Y") | |
if choice == '1': | |
print("Enter pincode") | |
pin_code_input = input() | |
rsp = requests.get( | |
"https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=" + pin_code_input + "&date=" + date) | |
else: | |
print("Enter state code") | |
state_code = input() | |
rsp = requests.get( | |
"https://cdn-api.co-vin.in/api/v2/appointment/sessions/calendarByDistrict?district_id= " + state_code + "&date=" + date) | |
while True: | |
try: | |
strrsp = rsp.text | |
jsonrsp = json.loads(strrsp) | |
centers = jsonrsp.get("centers") | |
b = False | |
for center in centers: | |
# print(center) | |
sessions = center.get("sessions") | |
for session in sessions: | |
if session.get("min_age_limit")==18: | |
hospital_name = center.get("name") + " " + center.get("block_name") + " " | |
pin_code = str(center.get("pincode")) | |
print("Center Name is : " + hospital_name + " " + "with pin code " + pin_code + " and available slots " + str(session.get("available_capacity")) + " on date : " + str(session.get("date") + " with session_id : " + session.get("session_id"))) | |
if session.get("available_capacity") > 0: | |
os.system('say "Covid vaccines are available"') | |
print(">>>>>>>>>>>>>>>>> beneficiaries : benficiaryID1 , benficiaryID2 : " + hospital_name + " with session_id : " + session.get("session_id")) | |
b = True | |
if b: | |
break | |
# Runs every 30 seconds or time mentioned below | |
time.sleep(10) | |
except Exception as e: | |
print(e) | |
for x in range(0,100): | |
os.system('say "Covid vaccines are available"') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment