-
Notifications
You must be signed in to change notification settings - Fork 1
/
dump.py
20 lines (16 loc) · 788 Bytes
/
dump.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# dump state/district metadata from cowin server lol
import requests
print("dumping...")
sta_dump = open("states.json", "w")
dis_dump = open("districts.json", "w")
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 Edg/90.0.818.51'}
states_response = requests.get('https://cdn-api.co-vin.in/api/v2/admin/location/states', headers=header)
states = states_response.json()
sta_dump.write(str(states))
sta_dump.close()
for sta in states['states']:
dis_response = requests.get('https://cdn-api.co-vin.in/api/v2/admin/location/districts/{0}'.format(sta['state_id']), headers=header)
districts = dis_response.json()
dis_dump.write(str(districts))
dis_dump.close()
print("done.")