Skip to content

rameshgitter/hostel_watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏠 IIEST Hostel Portal Watcher

A Python script that monitors the IIEST hostel portal for updates and sends email notifications when changes are detected.

📝 Description

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.

✨ Features

  • 🔐 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

🚀 Prerequisites

  • Python 3.x
  • pip (Python package installer)

📦 Installation

  1. Clone this repository:
git clone https://github.com/rameshgitter/hostel_watcher.git
cd hostel_watcher
  1. Install required packages:
pip install -r requirements.txt
  1. Create a .env file 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_USER

Note 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:

  1. Go to https://myaccount.google.com/apppasswords
  2. Sign in with your Google account
  3. Select "Mail" and your device type
  4. Click "Generate"
  5. You'll get a 16-character password (no spaces)
  6. Update your .env file with this password.

🎯 Usage

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.

  1. 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 named watcher.log in the project directory.
  2. Save and exit the editor.

    • If using nano:
      • Press Ctrl + O to write (save) the file. Press Enter to confirm.
      • Press Ctrl + X to exit.

Stopping the Cron Job

  1. Open your crontab editor again:

    crontab -e
  2. Delete the line you added for the hostel_watcher script.

  3. Save and exit the editor using the steps above.

Important Note on Cron Execution

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.

📝 License

About

A Python script that monitors the IIEST hostel portal for updates

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages