A Python script that monitors the IIEST hostel portal for updates and sends email notifications when changes are detected.
This script automatically monitors the IIEST hostel portal's student home page for any changes. When updates are detected, it sends an email notification to keep you informed about important announcements or changes in the portal.
- 🔐 Secure login to IIEST hostel portal
- 🔍 Monitors the student home page for changes
- 📧 Email notifications when updates are detected
- 💾 Maintains state between runs to detect changes
- 🛡️ Secure credential management using environment variables
- 🧹 Cleans up PHP errors and empty divs from the content
- Python 3.x
- pip (Python package installer)
- Clone this repository:
git clone https://github.com/rameshgitter/hostel_watcher.git
cd hostel_watcher- Install required packages:
pip install -r requirements.txt- Create a
.envfile in the project root with the following variables:
HOSTEL_ID=your_hostel_id
HOSTEL_PW=your_hostel_password
EMAIL_USER=your_gmail@gmail.com
EMAIL_PASS=your_gmail_app_password
TO_EMAIL=recipient@email.com # Optional, defaults to EMAIL_USERNote on Email Authentication: If you are using a Gmail account and have two-factor authentication enabled, you will need to generate an App Password to use as your
EMAIL_PASS. Follow these steps:
- Go to https://myaccount.google.com/apppasswords
- Sign in with your Google account
- Select "Mail" and your device type
- Click "Generate"
- You'll get a 16-character password (no spaces)
- Update your
.envfile with this password.
Run the script:
## 🔄 Automation
To run the script periodically, you can set up a cron job. This will automatically execute the script at specified intervals.
### Setting up a Cron Job
1. Open your crontab editor:
```bash
crontab -e
This will usually open in a text editor like nano.
-
Add the following line to run the script every minute:
* * * * * cd /home/ramesh/Desktop/hostel_watcher && python3.10 watcher.py >> watcher.log 2>&1
* * * * *: This is the cron expression for running every minute.cd /home/ramesh/Desktop/hostel_watcher: Changes the directory to your project folder.python3.10 watcher.py: Executes the python script. Make sure to use the correct python version if needed.>> watcher.log 2>&1: Appends both standard output and standard error to a file namedwatcher.login the project directory.
-
Save and exit the editor.
- If using
nano:- Press
Ctrl + Oto write (save) the file. PressEnterto confirm. - Press
Ctrl + Xto exit.
- Press
- If using
-
Open your crontab editor again:
crontab -e
-
Delete the line you added for the
hostel_watcherscript. -
Save and exit the editor using the steps above.
Cron jobs do not run when your laptop is turned off or suspended. If the system is off or asleep at the scheduled time, the job is skipped. Cron does not run missed jobs when the system powers back on.