-
-
Save debarko/45995919e2dc13d741b75215d393800d to your computer and use it in GitHub Desktop.
// This script will alert you whenever some slot opens up on the given date within the given District IDs | |
// Change the districts to your needs as per your city | |
// Change the dateArr to add your convinent set of dates | |
// For further update do checkout http://twitter.com/debarko/ | |
// How To setup Video -> https://www.youtube.com/watch?v=3_N5FFegtI4 | |
// Steps to use | |
// 1. Update Config | |
// 2. Login to https://selfregistration.cowin.gov.in/ | |
// 3. Rigt Click on the website | |
// 4. Click on Inspect | |
// 5. Open the Console Tab on your Inspect window | |
// 6. Copy paste the contents of this entire file - cowin_schedule_v2.js | |
// 7. Press Enter | |
// It will run every 10 seconds and check for availability of slots. | |
// Config | |
// ------ | |
var districts = [265, 276, 294, 277, 290, 266, 288, 292]; | |
var dateArr = ["30-05-2021", "31-05-2021", "01-06-2021"]; | |
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]; | |
await sleepNow(1100); | |
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 > 0) { | |
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(30000); | |
fetchByDistrict(); | |
} | |
console.log('Script Initialising'); | |
fetchByDistrict(); |
// This script will alert you whenever some slot opens up on the given date within the given pincodes | |
// Change the pincodes to your needs as per your city | |
// Change the dateArr to add your convinent set of dates | |
// For further update do checkout http://twitter.com/debarko/ | |
// How To setup Video -> https://www.youtube.com/watch?v=3_N5FFegtI4 | |
// Steps to use | |
// 1. Update Config | |
// 2. Login to https://selfregistration.cowin.gov.in/ | |
// 3. Rigt Click on the website | |
// 4. Click on Inspect | |
// 5. Open the Console Tab on your Inspect window | |
// 6. Copy paste the contents of this entire file - cowin_schedule_v2.js | |
// 7. Press Enter | |
// It will run every 10 seconds and check for availability of slots. | |
// Config | |
// ------ | |
var pincodes = ["560076", "560020", "560078", "560001", "560017", "560103", "560027", "560064", "560071", "560084", "560035", "560066", "560048"]; | |
var dateArr = ["30-05-2021", "31-05-2021", "01-06-2021"]; | |
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 fetchByPincode() { | |
console.log("Check: ", trialCounter++); | |
for (i=0;i < pincodes.length; i++) { | |
for (j=0; j < dateArr.length; j++) { | |
url = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/calendarByPin?pincode="+pincodes[i]+"&date="+dateArr[j]; | |
await sleepNow(1100); | |
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 > 0) { | |
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(30000); | |
fetchByPincode(); | |
} | |
console.log('Script Initialising'); | |
fetchByPincode(); |
Hi sidpagariya,
Thanks for reply. I got slot but not able to see captcha. I am running the script in cmd prompt.
could you please let me know how I can see proper captcha ?
Hello @newreddy, you can actually pull from the repository as I have now automated the captcha portion, thanks to https://github.com/sushrut111/cowin-automation-extn, especially @ayushchd
All you need to worry about is getting OTP now, and I will be pushing up some steps in the README to also automate the OTPs
Hi sidpagariya,
Thanks for reply. I got slot but not able to see captcha. I am running the script in cmd prompt.
could you please let me know how I can see proper captcha ?Hello @newreddy, you can actually pull from the repository as I have now automated the captcha portion, thanks to https://github.com/sushrut111/cowin-automation-extn, especially @ayushchd
All you need to worry about is getting OTP now, and I will be pushing up some steps in the README to also automate the OTPs
it has some issue, if enable auto refresh some exception coming and not able to relogin.
it has some issue, if enable auto refresh some exception coming and not able to relogin.
Let's move this over to https://github.com/sidpagariya/cowin-notifier/issues/new/choose and please describe your issue so we can get it resolved asap! :)
I have create 100% working and faster script to get CoWin vaccine slot availability alerts.
Please Check...
Thank varun,It is working as nicely.I took the vaccine today
Only we could have use pincode ,it would be more user friendlier
Hi sidpagariya,
Thanks for reply. I got slot but not able to see captcha. I am running the script in cmd prompt.
could you please let me know how I can see proper captcha ?