This Python script automatically scrapes the Sri Lankan Inland Revenue Department (IRD) "News and Notices" page. If it finds any new announcements published on the current day, it sends a consolidated email notification to a specified recipient using Gmail.
This is ideal for running as a daily automated task (e.g., a cron job) to stay updated on new tax circulars, notices, and publications.
- Scrapes the official IRD English news page: IRD News and Notices
- English, Sinhala and Tamil Language notification can be configuer.
- Parses HTML to find the title, description, link, and publication date of each notice.
- Filters for news items published on the current date.
- Sends a single email alert containing all of today's new items.
- Uses
smtplibto send email via a Google (Gmail) account.
- Python 3.7+
- A Google (Gmail) account to send emails from.
- A Google App Password for the sender's email account.
- Note: Your regular Gmail password will not work due to Google's security policies. You must generate an "App Password" to allow the script to log in.
- See: How to generate a Google App Password
-
Clone the Repository
git clone https://github.com/dilansalinda/IRD-News-Notifier.git cd IRD-News-Notifier -
Create a Virtual Environment (Recommended)
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies Create a
requirements.txtfile (as shown above) in the project directory and run:pip install -r requirements.txt
-
Set Environment Variables The script requires three environment variables to function. You must set these in your environment before running the script.
SENDER_EMAIL: The Gmail address the email will be sent from (e.g.,my-notifier@gmail.com).APP_PASSWORD: The 16-character Google App Password you generated.RECEIVER_EMAIL: The email address where you want to receive the alerts.BASE_URL: Base URL of IRD Sri Lanka.PATH: Path for IRD Sri Lanka web news and notices page.LANGUAGE: News and Notices language.
On Linux/macOS:
export SENDER_EMAIL="your-email@gmail.com" export APP_PASSWORD="your-16-char-app-password" export RECEIVER_EMAIL="recipient@example.com" export BASE_URL = "https://www.ird.gov.lk" //this should be update export PATH = "sitepages/News and Notices.aspx" //this should be update export LANGUAGE = "en" or "si" or "ti"
On Windows (Command Prompt):
set SENDER_EMAIL="your-email@gmail.com" set APP_PASSWORD="your-16-char-app-password" set RECEIVER_EMAIL="recipient@example.com" set BASE_URL = "https://www.ird.gov.lk" //this should be update set PATH = "sitepages/News and Notices.aspx" //this should be update set LANGUAGE = "en" or "si" or "ti"
Once your environment variables are set and dependencies are installed, just run the script:
python ird_news_notifier.py