CoWIN automation using selenium, AWS cloud and custom android app

Last week it has been a struggle like no other in my country – India. With the COVID-19 second wave gripping the entire country, the only option has been to get vaccinated as soon as possible. and to add to misery it has been almost impossible finding a slot through the official portal or application.

While the efforts of the govt are appreciable in such conditions, the fact still remains that finding & booking an appointment online is very difficult owing to the number of people that are competing for the same resources. Anyways long store short.. i wanted to make this a bit simpler for myself as i could not keep up with checking the portal manually myself (not to mention the seriously short period of session time before auto-logout).

The solution was to create a program that could do everything I do manually to at least keep an eye out for open slots. So I set out to create a small python program using selenium (with chromedriver) which can access and crawl the website for data and report back to me on mobile as soon as it sees available slots. Here is how it works:

  • Python code launches headless chrome using selenium and loads the vaccination booking portal in it.
  • The first page is where it asks for a mobile number. So here python fills in the mobile number and requests OTP for login.
  • OTP is sent to mobile.
  • A custom android app listens for incoming SMS from NHPSMS (source for Cowin SMS). the app catches the SMS and pushes it to the AWS API endpoint.
  • AWS API endpoint is connected to a lambda function which pushed the accompanying JSON data to a pre-configured AWS SNS topic. In the AWS console, i have created a subscription to the topic by email.
  • The OTP data is therefore pushed to my email by SNS.
  • Python program that initiated the OTP request checks the email account by the subject looking for the OTP. As OTP is found it enters it on the currently rendered login form in the headless chrome engine.
  • The program then proceeds to –
    search by pincode area
    of the portal. It enters my pin code and hits
    search
  • It then clicks on the filter –
    Age 18+
  • Finally, it takes a screenshot of the result and pushes it to me via telegram.
  • This is repeated every 5 minutes.

SCOPE FOR ENHANCEMENTS

  • The program can be made to look at the JSON data and notify only when it sees free slots
  • The program logic is open to completing the booking automatically without intervention. Since already got an appointment elsewhere I am not pursuing that part now.
  • The program can be made to keep hitting the search button every 1 minute to ensure we have the latest results in our view.

If you have trouble getting emails from this domain, please check your email spam & mark messages from flashvisions.com as 'Not Spam'

Comments are closed