2021年5月5日星期三

Javascript script for booking Vaccine slots

found this snippet on github which allows me to check slots - but I need to book them as well. Please let me know if any solutions.

var pincodes = ["411027", "411014", "411034", "411038", "411044", "411004", "411028"];  var dateArr = ["06-05-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(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 > 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(10000);      fetchByPincode();  }    console.log('Script Initialising');  fetchByPincode();    

found this snippet on github which allows me to check slots - but i need to book them as well. Please let me know if any solutions.

https://stackoverflow.com/questions/67411699/javascript-script-for-booking-vaccine-slots May 06, 2021 at 12:05PM

没有评论:

发表评论