Learn with your BUDDY

Learn with your BUDDY

Cowin-Scrape

Cowin-Scrape

A Python Application to get the number of vaccination centers available in your district.

Get the list of all latest vaccine information near you from Cowin India Website (cowin.gov.in)

⚡️ Quick start

First of all, download and install Python and your favourite IDE (I used PyCharm) and install the packages given in the requirements.txt file. Python Version 3.6 or higher is required.

Package installation can be done by using the pip install command:

pip install -r requirements.txt

Also, macOS and Linux users can check here to see pip install:


Note : It is recommended to create a virtual environment and install your packages inside the virtual environment

# Installing virtualenv
pip install virtualenv

# Creating virtual environment folder:
virtualenv venv


# Activating environment

# Windows
venv\Scripts\activate
# Mac / Linux:
venv/bin/activate

# Finally installing packages inside environment
pip install -r requirements.txt


Let's check your Cowin Scrape variables. Open cowin_scrape.py

clickDistOption = ""
clickStateSelect = ""
selectStateTarget = ""
clickDistrictSelect = ""
selectDistrictTarget = ""
searchBtn = ""


def init_var():
    global clickDistOption, clickStateSelect, selectStateTarget, clickDistrictSelect, selectDistrictTarget, searchBtn
    # initialising Cowin Variables
    clickDistOption = '//div[@id="mat-tab-label-0-1"]'
    clickStateSelect = '//span[@class="mat-select-placeholder mat-select-min-line ng-tns-c82-22 ng-star-inserted"]'
    selectStateTarget = '//mat-option[@id="mat-option-17"]'
    clickDistrictSelect = '//span[@class="mat-select-placeholder mat-select-min-line ng-tns-c82-24 ng-star-inserted"]'
    selectDistrictTarget = '//mat-option[@id="mat-option-48"]'
    searchBtn = '//button[@class="searchBtn pin-search-btn district-search"]'

As you can see, we need 6 variables.

#VariableTypeDefaultDescription
1.clickDistOptionstring'//div[@id="mat-tab-label-0-1"]'To click "Search by District" option.
2.clickStateSelectstring'//span[@class="mat-select-placeholder mat-select-min-line ng-tns-c82-22 ng-star-inserted"]'To click State dropdown menu.
3.selectStateTargetstring'//mat-option[@id="mat-option-17"]' ( value for Kerala )To select State from the dropdown menu.
4.clickDistrictSelectstring'//span[@class="mat-select-placeholder mat-select-min-line ng-tns-c82-24 ng-star-inserted"]'To click District dropdown menu.
5.selectDistrictTargetstring'//mat-option[@id="mat-option-48"]' ( value for Thiruvananthapuram )To select State from the dropdown menu.
6.searchBtnstring'//button[@class="searchBtn pin-search-btn district-search"]'To click "SEARCH" button.

Next, open Cowin Website (https://www.cowin.gov.in/) and fill in the variables according to respective state and district. Only Variables selectStateTarget, selectDistrictTarget are required to be changed.

Step 1: Inspect the website:


Step 2: Find your state and get the mat-option id:


Step 3: Find your district and get the mat-option id:


Step 4: After getting both state mat-option id and district mat-option id, pass it to the variables selectStateTarget, selectDistrictTarget

clickDistOption = ""
clickStateSelect = ""
selectStateTarget = ""
clickDistrictSelect = ""
selectDistrictTarget = ""
searchBtn = ""


def init_var():
    global clickDistOption, clickStateSelect, selectStateTarget, clickDistrictSelect, selectDistrictTarget, searchBtn
    # initialising Cowin Variables
    clickDistOption = '//div[@id="mat-tab-label-0-1"]'
    clickStateSelect = '//span[@class="mat-select-placeholder mat-select-min-line ng-tns-c82-22 ng-star-inserted"]'
    # Add State variable
    selectStateTarget = '//mat-option[@id="YOUR_STATE_MAT-OPTION_ID"]'
    clickDistrictSelect = '//span[@class="mat-select-placeholder mat-select-min-line ng-tns-c82-24 ng-star-inserted"]'
    # Add District variable
    selectDistrictTarget = '//mat-option[@id="YOUR_DISTRICT_MAT-OPTION_ID"]'
    searchBtn = '//button[@class="searchBtn pin-search-btn district-search"]'

That's all you need to do to start! ğŸŽ‰


🚚 Get the list of all vaccines

If you basically need just the number of vaccines and its details from the website, run main.py

python main.py

🔔 Please note: You can create your own custom project from main.py. Like getting vaccines from age group 18+ or get the details of only SPUTNIK V vaccine etc...
Such an example program can be found in noisy_alert.py where it finds COVISHIELD and SPUTNIK V vaccines for the age group 18+.


🚚 Get alert if a vaccine is available

noisy_alert.py finds COVISHIELD and SPUTNIK V vaccines for the age group 18+ and starts playing sound (audio2.mp3) if a vaccine slot was available.

python noisy_alert.py


⭐️ Project assistance

If you want to say thank you or/and support active development of Cowin-Scrape:

Together, we can make this project better every day! 😘


🛠️ Built With

❤️ Authors

  • Abhijith Udayakumar - Design & Development - Abhijith14



🚨 Forking this repo (please read!)

yes, with attribution.

I value keeping my work open source, but as you all know, plagiarism is bad. It's always disheartening whenever I find that someone has copied my work without giving me credit. I spent a non-trivial amount of effort building and designing this project, and I am proud of it! All I ask of you all is to not claim this effort as your own.

TL;DR

Yes, you can fork this repo. Please give me proper credit by linking back to Abhijith14/Cowin-Scrape. Thanks!

 
Share this