Created
May 16, 2021 18:31
-
-
Save hrik2001/fc91d002150d90aaf9836d37451ce0ff to your computer and use it in GitHub Desktop.
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 time | |
import datetime | |
import json | |
def search_pincode(numdays , pincode , min_age_limit = 18): | |
''' | |
numdays -- int that makes you look n days into the future | |
pincode -- put pincode in string | |
min_age_limit -- put 18 for 18+ (default) , 45 for 45+ and 0 for everyone | |
''' | |
today = datetime.datetime.today() | |
dates = [today + datetime.timedelta(days=x) for x in range(numdays)] | |
datestr = [x.strftime("%d-%m-%Y") for x in dates] | |
for i in datestr: | |
print("..............................................................................") | |
print("For date " + i) | |
headers = { | |
'accept': 'application/json', | |
'Accept-Language': 'hi_IN', | |
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', #because the website asks for useragent | |
} | |
params = ( | |
('pincode', pincode), | |
('date', i), | |
) | |
response = requests.get('https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByPin', headers=headers, params=params) | |
# print(response.text) | |
response_dict = json.loads(response.text) | |
centres = response_dict["sessions"] | |
for i in centres: | |
if i["min_age_limit"] == min_age_limit or min_age_limit == 0: | |
print("-----") | |
print("Name :: " , i["name"]) | |
print("Address :: ", i["address"]) | |
print("District :: " , i["district_name"]) | |
print("Dose 1 :: ", i["available_capacity_dose1"]) | |
print("Dose 2 :: ", i["available_capacity_dose2"]) | |
print("Available Capacity :: ", i["available_capacity"]) | |
print("Vaccine :: " , i["vaccine"]) | |
print("Fees :: " , i["fee"]) | |
print("Slots :: " , i["slots"]) | |
print("Age :: " , i["min_age_limit"]) | |
print("-----") | |
print("..............................................................................") | |
if __name__ == "__main__": | |
while True: | |
print("##############################################") | |
search_pincode(20 , "201301") | |
print("##############################################") | |
time.sleep(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment