A Telegram bot that helps users find rental properties by scraping listings from Madlan.
Directory structure:
└── kobia77-rent-find-bot.git/
├── bot.py
├── chromedriver/
│ ├── LICENSE.chromedriver
│ └── THIRD_PARTY_NOTICES.chromedriver
├── scrapers/
│ ├── __init__.py
│ ├── madlan_scraper.py
│ ├── madlan_scraper_sl.py
│ └── __pycache__/
└── tools/
├── __init__.py
├── pagination.py
├── search.py
├── start.py
└── __pycache__/
- bot.py: The main entry point for the Telegram bot, handling command and message interactions.
- chromedriver/: Contains the ChromeDriver and related licensing files required for Selenium-based web scraping.
- scrapers/: Includes modules for scraping rental listings from Madlan using both requests/BeautifulSoup and Selenium.
- madlan_scraper.py: Scrapes rental data using requests and BeautifulSoup.
- madlan_scraper_sl.py: Uses Selenium (with undetected_chromedriver) to scrape rental listings.
- tools/: Contains utility modules to support pagination, search logic, and bot start-up functions.
- pagination.py: Manages pagination of search results and user interactions.
- search.py: Implements search functionality by scraping and filtering rental listings.
- start.py: Defines the start command that initializes the bot conversation.
- Telegram Bot Integration: Interacts with users via Telegram to gather rental search criteria.
- Web Scraping: Extracts rental listing data from the Madlan website using both traditional HTTP requests and Selenium.
- Search & Filtering: Searches for rental properties based on user-specified location and maximum price.
- Pagination: Provides listings in paginated form for easy user navigation.
- User-Friendly Interface: Guides users through the rental search process with clear prompts.
- Clone the Repository
- Install Required Packages
- python-telegram-bot
- python-dotenv
- requests
- beautifulsoup4
- undetected-chromedriver
- selenium
-
Set Up Environment Variables: Create a .env file in the project root with your Telegram bot token:
BOT_TOKEN=your_telegram_bot_token -
Run the Bot:
python bot.pyThe bot will start and listen for incoming messages on Telegram. Use the /start command to begin your rental search.