Skip to content

Instantly share code, notes, and snippets.

@debarko
Last active May 31, 2021 12:20
Show Gist options
  • Save debarko/3ae329079e9b2b17cb418c90e8bd86ea to your computer and use it in GitHub Desktop.
Save debarko/3ae329079e9b2b17cb418c90e8bd86ea to your computer and use it in GitHub Desktop.
Covaxin Dose 2 Locator By District
// PLEASE READ THE NEXT FEW LINES
// Change district IDs to your required ones as per this link -> https://tinyurl.com/p9e539zt (Thanks @bhattbhavesh91 for creating the CSV)
// Change the date (No need to add more than 1 date, it will fetch for next 7 days from the entered date)
// Change the vaccine_name to whichever vaccine you need for 2nd dose.
// Video to setup a similar script -> https://www.youtube.com/watch?v=3_N5FFegtI4
// Note the above video doesn't use the same script, use the same steps but copy this script. Rest all steps are same.
// Config
var districts = [294, 265];
var dateArr = ["31-05-2021"];
var vaccine_name = "COVAXIN";
//Options for Vaccine_name
// COVAXIN
// COVISHIELD
// DO NOT TOUCH BELOW THIS LINE
var trialCounter = 1;
const sleepNow = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
async function fetchByDistrict() {
console.log("Check: ", trialCounter++);
for (i=0;i < districts.length; i++) {
for (j=0; j < dateArr.length; j++) {
url = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/calendarByDistrict?district_id="+districts[i]+"&date="+dateArr[j]+"&vaccine="+vaccine_name;
await sleepNow(1000);
a = httpGet(url);
try {
a = JSON.parse(a)
} catch(e) {
continue;
}
for (c in a.centers) {
for (s in a.centers[c].sessions) {
if (a.centers[c].sessions[s].min_age_limit < 45 && a.centers[c].sessions[s].available_capacity_dose2 > 0 && a.centers[c].sessions[s].vaccine != "COVISHIELD") {
console.log("Trying Booking for", a.centers[c].pincode, a.centers[c].name, a.centers[c].sessions[s].available_capacity);
var audio = new Audio('https://media.geeksforgeeks.org/wp-content/uploads/20190531135120/beep.mp3');
audio.play();
}
}
}
}
}
await sleepNow(9000);
fetchByDistrict();
}
console.log('Script Initialising');
fetchByDistrict();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment