Skip to content

This Python script scrapes the top 5 gainers and losers from the NSE India website using Selenium and sends an email with the data in tabular HTML format.

Notifications You must be signed in to change notification settings

RishabhDhawad/Scraping-NSE-India

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

📈 NSE Top Gainers and Losers Email Notifier

This Python script scrapes the top 5 gainers and losers from the NSE India website using Selenium and sends an email with the data in tabular HTML format.


🚀 Features

  • Scrapes top 5 gainers and losers from NSE daily market snapshot.
  • Sends an HTML email with the extracted data.
  • Uses environment variables for secure credentials.
  • Configurable SMTP email delivery (supports Gmail, Outlook, etc.).

🧰 Tech Stack

  • Python 3.x
  • Selenium
  • Chrome WebDriver (via webdriver-manager)
  • smtplib for sending emails
  • dotenv for managing environment variables

📦 Setup Instructions

1. Clone the Repository

git clone https://github.com/your-username/nse-market-snapshot.git
cd nse-market-snapshot

2. Install Dependencies

pip install -r requirements.txt

3. Create a .env File

Create a .env file in the root directory with the following content:

SMTP_SERVER = smtp.gmail.com
SMTP_PORT = 587
SENDER_EMAIL = [email protected]
SENDER_PASSWORD = your_email_password_or_app_password
RECEIVER_EMAIL = [email protected]

⚠️ For Gmail, enable App Passwords if 2FA is on.

🧪 Running the Script

pip install -r requirements.txt

This will:

  • Open NSE website using headless Chrome
  • Navigate to the "Top Gainers/Losers" section
  • Extract top 5 from each
  • Send a formatted HTML email

🛠 Customization

Schedule the script with cron (Linux/macOS) or Task Scheduler (Windows) for daily execution. Example cron entry to run every weekday at 4:15 PM:

15 16 * * 1-5 /usr/bin/python3 /path/to/main.py

🔐 Security Note

Do not hardcode credentials. Use the .env file and keep it out of version control (.gitignore it).

📸 Sample Output

A sample email body:

Subject: 📈 NSE Top 5 Gainers and Losers Today

Top 5 Gainers

SYMBOL LTP %CHNG
ABC ₹123.45 +5.6%
... ... ...

Top 5 Losers

SYMBOL LTP %CHNG
XYZ ₹98.76 -4.3%
... ... ...

🧾 License

This project is for educational and personal use only. NSE data is copyrighted and scraping may be restricted.

👨‍💻 Author

Rishabh Dhawad

Made with ❤️ and Python 🐍

About

This Python script scrapes the top 5 gainers and losers from the NSE India website using Selenium and sends an email with the data in tabular HTML format.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages