├── README.md ├── meta └── vac.png ├── requirements.txt └── vac_checker.py /README.md: -------------------------------------------------------------------------------- 1 | # vaccine -------------------------------------------------------------------------------- /meta/vac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/vaccine/HEAD/meta/vac.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pandas 2 | streamlit==0.79.0 3 | Pillow 4 | fake-useragent 5 | -------------------------------------------------------------------------------- /vac_checker.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | from PIL import Image 3 | from fake_useragent import UserAgent 4 | import requests 5 | import pandas as pd 6 | 7 | ua = UserAgent() 8 | header = {'User-Agent': str(ua.chrome)} 9 | 10 | def run(): 11 | img1 = Image.open('./meta/vac.png') 12 | img1 = img1.resize((350,250)) 13 | st.image(img1,use_column_width=False) 14 | 15 | 16 | st.markdown("

* Data displayed in this website are fetched from authentic Government databases *

", 17 | unsafe_allow_html=True) 18 | 19 | ## Area Pin 20 | area_pin = st.text_input('Enter your area\'s Pin-Code Eg.712311') 21 | 22 | ## Date 23 | st.markdown("

Please enter a date to check availability

",unsafe_allow_html=True) 24 | vac_date = st.date_input("Date") 25 | st.markdown(" ") 26 | ## Age 27 | st.markdown("

Enter age group, 18 - 45 or above 45

",unsafe_allow_html=True) 28 | age_display = ['18-45','45+'] 29 | age = st.selectbox("Your Age Group",age_display) 30 | 31 | if st.button("Search"): 32 | try: 33 | vac_date = str(vac_date).split('-') 34 | new_date = vac_date[2]+'-'+vac_date[1]+'-'+vac_date[0] 35 | age_val = 0 36 | if age == '18-45': 37 | age_val = 18 38 | else: 39 | age_val = 45 40 | response = requests.get( 41 | f"https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode={area_pin}&date={new_date}", 42 | headers=header) 43 | data = response.json() 44 | centers = pd.DataFrame(data.get('centers')) 45 | if centers.empty: 46 | st.warning("Sorry! No centres found for "+new_date+' in '+str(area_pin)+' Check Later!') 47 | else: 48 | session_ids = [] 49 | for j, row in centers.iterrows(): 50 | session = pd.DataFrame(row['sessions'][0]) 51 | session['center_id'] = centers.loc[j, 'center_id'] 52 | session_ids.append(session) 53 | 54 | sessions = pd.concat(session_ids, ignore_index=True) 55 | av_centeres = centers.merge(sessions, on='center_id') 56 | av_centeres.drop(columns=['sessions', 'session_id', 'lat', 'block_name', 'long','date', 'from', 'to','state_name','district_name','pincode','vaccine_fees'], inplace=True,errors='ignore') 57 | av_centeres = av_centeres[av_centeres['min_age_limit'] == age_val] 58 | # print(av_centeres) 59 | print(av_centeres.columns) 60 | new_df = av_centeres.copy() 61 | print(new_df) 62 | new_df.columns = ['Center_ID', 'Name', 'Address', 'Fee', 63 | 'Availability', 'Minimum Age', 'Vaccine Type', 'Timing'] 64 | new_df = new_df[['Center_ID', 'Name', 'Fee', 65 | 'Availability', 'Minimum Age', 'Vaccine Type', 'Timing','Address']] 66 | st.dataframe(new_df.assign(hack='').set_index('hack')) 67 | 68 | 69 | except Exception as e: 70 | st.error("Something went wrong!!") 71 | print(e) 72 | 73 | 74 | st.markdown("

Made by Mainak Chaudhuri

",unsafe_allow_html=True) 75 | 76 | run() --------------------------------------------------------------------------------