Skip to content

Instantly share code, notes, and snippets.

@py-ranoid
Created May 5, 2021 09:02
Show Gist options
  • Save py-ranoid/f57f918f080d9891fedd7de28b3ee733 to your computer and use it in GitHub Desktop.
Save py-ranoid/f57f918f080d9891fedd7de28b3ee733 to your computer and use it in GitHub Desktop.
import requests, datetime, time
PINCODE, WAIT = '600096', 60
def notify(available_sessions):
print("SESSIONS AVAILABLE :%r"%available_sessions)
while True:
resp = requests.get('https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=600096&date=%s'%datetime.datetime.now().strftime("%d-%m-%Y")).json()
all_sessions = [(center['name'], session['date'], session['available_capacity']) for center in resp['centers'] for session in center['sessions'] if session['min_age_limit']==18]
available_sessions = [i for i in all_sessions if i[2]]
if available_sessions: notify(available_sessions)
time.sleep(WAIT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment