diff --git a/Python/Covid_Vaccination_Center_Locator/README.md b/Python/Covid_Vaccination_Center_Locator/README.md new file mode 100644 index 00000000..2b201011 --- /dev/null +++ b/Python/Covid_Vaccination_Center_Locator/README.md @@ -0,0 +1,56 @@ +# Covid_Vaccination_center_locator + +A script to find the available covid vaccination center in the specified pincode. +When you run the code, it asks for the pincode of the place and date where you want to know the availability of center. +The script store the real time information about the center into the json file and read it and shows in the terminal. + + +# Technology Used + +Restful APIs from api setu + +Request module + + +# Run Locally + +Run ```covid_vaccine_locator.py``` + +```python + python covid_vaccine_locator.py +``` + + +# Output + +This python script runs and output the json file and read it to the terminal. + +## ''' + +Center Name : NEW DELHI MEDICAL CENTRE +Address : 1st Floor Hemkunt Tower Rajendra Place New Delhi, Central Delhi, Delhi + +Total Capacity : 700 + +Dose1 : 300 + +Dose2 : 400 + +Price : 780 + +Center Name : NEW DELHI MEDICAL CENTRE + +Address : 1st Floor Hemkunt Tower Rajendra Place New Delhi, Central Delhi, Delhi + +Total Capacity : 700 + +Dose1 : 300 + +Dose2 : 400 + +Price : 780 + +## ''' + +# Author +https://github.com/das88768 diff --git a/Python/Covid_Vaccination_Center_Locator/covid_vaccine_locator.py b/Python/Covid_Vaccination_Center_Locator/covid_vaccine_locator.py new file mode 100644 index 00000000..1013ff9a --- /dev/null +++ b/Python/Covid_Vaccination_Center_Locator/covid_vaccine_locator.py @@ -0,0 +1,46 @@ +import requests +import json + +pincode = input("Enter the pincode of the area : ") +date = input("Enter the date to get vaccinate (dd-mm-yyyy): ") + +url = f'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByPin?pincode={pincode}&date={date}' +response = requests.get(url) +print(f"Status Code : {response.status_code}") + +response_dict = response.json() +vacc_dicts = response_dict['sessions'] + +filename = 'vaccine_info.json' +with open(filename, 'w') as file: + json.dump(response_dict, file, indent=4) + +if vacc_dicts: + vacc_info_dicts = [] + for vacc_dict in vacc_dicts: + if vacc_dict['fee_type'] == 'Paid': + fee = vacc_dict['fee'] + else: + fee = 'Free' + + vacc_info = { + 'center_name': vacc_dict['name'], + 'address': f"{vacc_dict['address']}, {vacc_dict['district_name']}, {vacc_dict['state_name']}", + 'vacc_name': vacc_dict['vaccine'], + 'total_capacity': vacc_dict['available_capacity'], + 'capacity_dose1': vacc_dict['available_capacity_dose1'], + 'capacity_dose2': vacc_dict['available_capacity_dose2'], + 'fees': fee, + } + vacc_info_dicts.append(vacc_info) + + for info in vacc_info_dicts: + print(f"\nCenter Name : {info['center_name']}") + print(f"Address : {info['address']}") + print(f"Total Capacity : {info['total_capacity']}") + print(f"Dose1 : {info['capacity_dose1']}") + print(f"Dose2 : {info['capacity_dose2']}") + print(f"Price : {info['fees']}") + +else: + print("Vaccination Closed") \ No newline at end of file