This is a Python script which will help you to know when a slot is available on Cowin website.
This script has been tested with Python version 3.6, 3.8 on Linux/MacOs. In case you want to run it with Python 2.7 or Windows, some changes might be required.
The main code is in the file slot_checker.py. Rest everything is optional in case you want to run it as a cron job.
Explanation for all the configuration that can be found in slot_checker.py
Config | Info |
---|---|
DISTRICT_IDS | This is the list of districts to check for free slot. You can get your district id in DISTRICT_LISTS. Example. [(294, "BBMP"), (265, "Bengaluru Urban")] will find slots in BBMP and Bengaluru Urban districts. Change this id and name to your district. |
WRITE_TO_FILE | Optional. Write the free slots to a file. Default: True |
FILE_NAME | Optional. File to which to write the open slots to. Default: "vaccine.txt" |
FILE_OPEN | Optional. Wheater to open the file, if WRITE_TO_FILE is enabled. |
ALARM | Optional. This will ring an alarm when free slots are found. Default: True |
NUM_WEEKS | No of weeks starting today to check the slots in. Default: 5 |
MIN_AGE | Array that can used to check for 18-44 or 45+ age groups. Default : Both |
OPEN_PAGE | Optional. This will open the self registration page when free slots are found. Default: True |
pip install -r requirements.txt
python3 slot_checker.py
Cron job are periodic jobs that will run silently in the background automatically. There is a cron helper script slot_script.sh in the repo, however you might have to make some changes to cron_script according to your environment.
crontab -e
* * * * * <PATH_TO_THE_REPO>/cron_script.sh
MAILTO="""
above the previous command.Note: There is
MIN_CAPACITY
config in the main file. Change it to maybe5
, so that your laptop does not keep alerting you when a single slot opens up because most likely it is going to filled by the time you sign in onto the portal.Note: To check if this cron is running properly, you can check if the file with FILE_NAME got created. Another way is to check terminal mail. The terminal is going to create a mail for every time the cron runs. To check, go to terminal and run