This script sends you updates regularly about the the statistics of the people infected by covid-19 in all states in India.
This code is written entirely in python 3. The following libraries are necessary.
- BeautifulSoup4
- tabulate
- requests You can install them by following commands (for linux users):
pip install beautifulsoup4
pip install tabulate
pip install requests
When ever there is a change in the data, the script automatically sends a message similar to this.
This will help you run the script at regular time intervals. Ofcourse you have to keep your computer on.
- Open your terminal and run this command
- crontab -e
- Append this text to run the scirpt every 20 mins
- */20 * * * * cd < PATH TO WORKING DIRECTORY >; python main.py
For more info on cron-deamon click this link
- What if a new state is added: I had deployed this script. But when a new state was added my script stopped working. Resolved this by making small changes in code and by writing the whole code inside a try block and in the except block i made sure that i would get an error message if the script doesn't work.
- When the data already stored is lost by accident: If by any chance the data is lost (i deleted the json file) it shot an error. I tried making it more robust by automatically creating a new database and start storing the data from that time stamp and send a message to the user that the database was lost and new database has been initialised.
You get a webhook when you create an app. Using the web hook you can easily send the message to your thread. If you are working in machine learning , you can use the code to get updates about how much the training has been done. You can get notifications on phone if you install the app. Make an auth.py file in the working directory and store your webhook in this file. Type the following command in your teminal.
touch auth.py
Finally i have a data set, which is almost ready for a time series analysis
If you feel that i can further improve my code, please feel free to contact me.