Skip to content

njreyesc/streamlit-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Website Registration Monitor

A Python application that monitors website registration pages and sends Telegram notifications when registration status changes.

Features

  • Monitors multiple URLs for registration availability
  • Sends real-time alerts via Telegram
  • Comprehensive error handling and logging
  • Configurable check intervals
  • Headless Chrome browser automation

Refactoring Changes

This application has been completely refactored with the following improvements:

Security

  • Removed hardcoded credentials - Now uses environment variables
  • Added .env.example template for secure configuration

Code Quality

  • Object-oriented design - Introduced TelegramNotifier and WebsiteMonitor classes
  • Proper error handling - Try-except blocks with specific exception handling
  • Context managers - File operations use with statements
  • Type hints - Added for better code clarity
  • Logging - Comprehensive logging to file and console
  • Clean imports - Removed duplicates and unused imports

Functionality

  • Fixed scheduler logic - Removed broken scheduler implementation
  • Simplified main loop - Clear, maintainable monitoring loop
  • Configurable settings - Environment-based configuration
  • Graceful shutdown - Proper cleanup on exit

Setup

Prerequisites

  • Python 3.7+
  • Chrome/Chromium browser
  • ChromeDriver (matching your Chrome version)

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Copy the example environment file:
cp .env.example .env
  1. Edit .env and add your credentials:
    • Get a Telegram bot token from @BotFather
    • Get your chat ID by messaging your bot and visiting: https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates

Configuration

Edit your .env file:

TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT_ID=your_chat_id_here
CHECK_INTERVAL=30  # Check every 30 seconds
SEARCH_STRING=нитЕ  # String to search for

Usage

Run the monitor:

python streamlit_app.py

To load the .env file automatically, you can:

  1. Use python-dotenv in the code (add from dotenv import load_dotenv; load_dotenv() at the top)
  2. Or export variables manually:
export $(cat .env | xargs)
python streamlit_app.py

How It Works

  1. The monitor checks specified URLs at regular intervals
  2. It searches for a specific string on each page
  3. When the string is found: Registration is likely CLOSED
  4. When the string is not found: Registration may be OPEN
  5. Telegram alerts are sent for each check result

Logs

  • Console output shows real-time monitoring status
  • monitor.log file contains detailed logs
  • All errors and alerts are logged

Stopping the Monitor

Press Ctrl+C to gracefully stop the monitor. It will clean up temporary files before exiting.

Security Notes

  • Never commit your .env file - It contains sensitive credentials
  • Keep your Telegram bot token secret
  • The .env.example file is safe to commit (contains no real credentials)

License

This is a monitoring tool for personal use. Ensure you have permission to monitor any websites you configure.

About

Example Streamlit app that you can fork to test out share.streamlit.io

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%