Skip to content

amharnisfar/tg-proxy-scraper-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Proxy Scraper Bot - By Amhar Nisfer

Bot Banner
PythonDockerSeleniumTelegram

A sophisticated, containerized Telegram bot that scrapes free proxy details from onlineproxy.io. This tool is designed for users who need quick access to fresh proxies from various countries directly within their Telegram messenger, with easy deployment thanks to Docker.

🌟 Features

  • Dynamic Web Scraping: Utilizes Selenium to navigate a JavaScript-heavy website, demonstrating advanced scraping techniques.
  • Interactive Telegram Bot: A user-friendly bot interface built with the python-telegram-bot library.
  • Multi-Country Support: Easily fetch proxies from a predefined list of countries.
  • Containerized Deployment: Comes with a Dockerfile for easy, consistent, and isolated deployment.
  • Secure Configuration: Employs environment variables for API tokens, keeping your credentials safe.
  • Robust Error Handling: Gracefully manages web scraping timeouts and bot command issues.
  • Asynchronous Operations: Leverages asyncio for non-blocking execution, ensuring a responsive bot.

🚀 Getting Started

You can run this bot either locally with a Python environment or using Docker. The Docker method is recommended for ease of use and consistency.

Prerequisites

  • For Docker Deployment: Docker installed on your system.
  • For Local Development:
    • Python 3.9+
    • Google Chrome browser
    • pip for package management

🐳 Docker Deployment (Recommended)

Containerizing the bot simplifies dependency management and provides a stable environment.

  1. Clone the Repository:
    git clone https://github.com/amharnisfar/tg-proxy-scraper-bot.git
    

    cd tg-proxy-scraper-bot

  2. Build the Docker Image:

    This command builds the image using the provided Dockerfile. It will install all necessary system and Python dependencies.

    docker build -t proxy-scraper-bot .
  3. Run the Docker Container:

    You must provide your Telegram Bot Token as an environment variable (-e) when running the container.

    docker run -d --name proxy-bot-instance -e TELEGRAM_BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN" proxy-scraper-bot
    • -d: Runs the container in detached mode (in the background).
    • --name proxy-bot-instance: Assigns a memorable name to your container.

    Your bot is now running inside a Docker container!

Managing the Docker Container

  • View Logs:
    docker logs -f proxy-bot-instance
  • Stop the Container:
    docker stop proxy-bot-instance
  • Restart the Container:
    docker start proxy-bot-instance

💻 Local Development Setup

If you prefer to run the bot directly on your machine, follow these steps.

  1. Clone the repository:
  2. Create a virtual environment:
    python -m venv venv
    source venv/bin/activate  # On Windows, use venv\Scripts\activate
  3. Install the required dependencies:

    The requirements.txt file contains all the necessary Python packages.

    pip install -r requirements.txt
  4. Set up your Telegram Bot Token:

    Talk to the BotFather on Telegram to create a new bot and get your API token. Then, set it as an environment variable.

    On Linux/macOS:

    export TELEGRAM_BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN"

    On Windows:

    set TELEGRAM_BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN"
  5. Run the Bot:
    python bot.py

🤖 How to Use the Bot

Interact with the bot on Telegram using the following commands:

  • /start - Displays a welcome message and the list of available countries.
  • /help - Provides instructions on how to use the /proxy command.
  • /proxy <country_name> - Scrapes and returns up to four proxies for the specified country.

Example: /proxy united-states

🛠️ How It Works

Telegram Bot

The bot is built using the python-telegram-bot library. It listens for commands from users and triggers the appropriate actions. It uses asyncio to handle multiple user requests concurrently without blocking.

Web Scraper

The web scraper is built with Selenium. When a user requests proxies, the scraper:

  1. Launches a headless Chromium browser inside the container.
  2. Navigates to the corresponding URL on onlineproxy.io.
  3. Locates the active proxy listings and avoids archived ones.
  4. Iteratively clicks on each proxy to open a details modal.
  5. Interacts with the modal to reveal the full proxy credentials.
  6. Extracts the protocol, IP, port, login, and password.
  7. Returns the scraped data to the bot, which then formats and sends it to the user.

📂 Project Structure

your_repository/
│
├── Dockerfile              # Instructions for building the Docker image
├── bot.py                  # Main Python script for the bot and scraper
├── requirements.txt        # List of Python dependencies
└── README.md               # This file

🤝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

© 2025 Amhar Nisfer Dev, Inc.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors