A secure, professional, and efficient web scraper for monitoring car listings on Auto.de. This bot automatically collects car information including make, model, price, specifications, and stores them in a local database with Telegram notifications for errors.
This project is strictly for educational purposes only. The responsibility for how this code is used lies entirely with the user. The authors of this project do not assume any liability for misuse or any damages arising from the use of this code.
Before using this bot:
- Review Auto.de's Terms of Service and robots.txt
- Ensure compliance with applicable laws and regulations
- Use rate limiting and respectful scraping practices
- Do not overload the target server
- β Request Timeout Protection - Prevents hanging on unresponsive servers
- β SSL/TLS Verification - Protects against MITM attacks
- β Rate Limiting - Prevents server overload and IP bans
- β Input Validation & Sanitization - Prevents injection attacks
- β Retry Mechanism - Exponential backoff for failed requests
- β Error Handling - Comprehensive exception handling
- β Secure Configuration - Environment variables for sensitive data
- β robots.txt Compliance - Optional ethical scraping checks
- π Automated scraping of car listings from Auto.de
- πΎ SQLite database storage with proper schema
- π Telegram notifications for errors and critical events
- π Statistics tracking (runs, successes, failures)
- π§Ή Automatic cleanup of old listings
- π Comprehensive logging to file and console
- π Graceful shutdown handling (SIGINT/SIGTERM)
- βοΈ Highly configurable via environment variables
- Modular Design - Separated concerns (config, common utilities, main bot)
- Object-Oriented - Clean class-based structure
- Type Hints - Python typing for better code quality
- Professional Code - Follows Python best practices (PEP 8)
- Python 3.8 or higher
- pip (Python package manager)
- Internet connection
- Telegram Bot (optional, for notifications)
git clone https://github.com/mxyldrm/autodebotscrapper.git
cd autodebotscrapper# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Linux/Mac:
source venv/bin/activate
# On Windows:
venv\Scripts\activatepip install -r requirements.txtCopy the example environment file and edit it with your settings:
cp .env.example .envEdit .env file with your favorite text editor:
nano .env # or vim, code, etc.Required Configuration:
# Telegram Bot Configuration (Get from @BotFather)
TELEGRAM_API_KEY=your_telegram_bot_api_key_here
TELEGRAM_CHAT_ID=your_telegram_chat_id_hereOptional Configuration (with defaults):
# Scraping Configuration
MAX_PAGES=5 # Number of pages to scrape (default: 5)
REQUEST_TIMEOUT=30 # Request timeout in seconds (default: 30)
RATE_LIMIT_REQUESTS=10 # Max requests per time window (default: 10)
RATE_LIMIT_WINDOW=60 # Rate limit time window in seconds (default: 60)
# Database Configuration
DATABASE_PATH=autode_cars.db # SQLite database path (default: autode_cars.db)
DELETE_OLD_CARS_DAYS=7 # Delete cars older than N days (default: 7)
# Logging Configuration
LOG_LEVEL=INFO # Logging level (DEBUG, INFO, WARNING, ERROR)
LOG_FILE=autode_bot.log # Log file path (default: autode_bot.log)
# Bot Behavior
MAIN_LOOP_INTERVAL=300 # Seconds between scraping cycles (default: 300 = 5 min)
CHECK_ROBOTS_TXT=true # Check robots.txt before scraping (default: true)To receive error notifications via Telegram:
-
Create a Telegram Bot:
- Open Telegram and search for
@BotFather - Send
/newbotcommand - Follow the instructions to create your bot
- Copy the API token (e.g.,
123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
- Open Telegram and search for
-
Get Your Chat ID:
- Search for
@userinfoboton Telegram - Start a chat and it will show your chat ID
- Copy the numeric chat ID (e.g.,
987654321)
- Search for
-
Add to .env file:
TELEGRAM_API_KEY=123456789:ABCdefGHIjklMNOpqrsTUVwxyz TELEGRAM_CHAT_ID=987654321
python auto_de_bot.pyThe bot will:
- Validate configuration
- Start continuous monitoring loop
- Scrape Auto.de listings every 5 minutes (configurable)
- Store car information in SQLite database
- Clean up old listings (older than 7 days by default)
- Send error notifications to Telegram if configured
- Log all activities to
autode_bot.log
Press Ctrl+C to gracefully shut down the bot. It will:
- Complete the current operation
- Save final statistics to log
- Close database connections properly
# View real-time logs
tail -f autode_bot.log
# Search for errors
grep ERROR autode_bot.log
# View last 100 lines
tail -n 100 autode_bot.log# Open SQLite database
sqlite3 autode_cars.db
# Example queries:
sqlite> SELECT COUNT(*) FROM cars;
sqlite> SELECT * FROM cars ORDER BY created_at DESC LIMIT 10;
sqlite> SELECT model_make, price FROM cars WHERE price < 20000;
sqlite> .exitautodebotscrapper/
βββ auto_de_bot.py # Main bot application
βββ common.py # Common utilities (logging, database, sanitization)
βββ config.py # Configuration and settings
βββ requirements.txt # Python dependencies
βββ .env # Environment variables (create from .env.example)
βββ .env.example # Example environment configuration
βββ .gitignore # Git ignore rules
βββ README.md # This file
βββ autode_bot.log # Log file (created on first run)
βββ autode_cars.db # SQLite database (created on first run)
CREATE TABLE cars (
id TEXT PRIMARY KEY, -- Unique car ID from Auto.de
model_make TEXT NOT NULL, -- Car make and model
price REAL, -- Price in EUR
link TEXT, -- Direct link to listing
image_url TEXT, -- Car image URL
company TEXT, -- Platform (autode)
transmission TEXT, -- Manual/Automatic
mileage INTEGER, -- Mileage in km
first_registration INTEGER, -- First registration year
fuel_type TEXT, -- Petrol/Diesel/Electric/Hybrid
power_data TEXT, -- Power in KW and PS
co2_emission TEXT, -- CO2 emissions
consumption TEXT, -- Fuel consumption
created_at TIMESTAMP, -- When first added
updated_at TIMESTAMP -- Last update time
);Adjust rate limiting to be more or less aggressive:
# Conservative (safer)
RATE_LIMIT_REQUESTS=5
RATE_LIMIT_WINDOW=60
# Default (balanced)
RATE_LIMIT_REQUESTS=10
RATE_LIMIT_WINDOW=60
# Aggressive (not recommended)
RATE_LIMIT_REQUESTS=20
RATE_LIMIT_WINDOW=60Change how often the bot runs:
# Every 5 minutes (default)
MAIN_LOOP_INTERVAL=300
# Every 15 minutes (recommended for production)
MAIN_LOOP_INTERVAL=900
# Every hour
MAIN_LOOP_INTERVAL=3600- Never commit
.envfile - It contains sensitive credentials - Use strong Telegram bot tokens - Keep them secret
- Enable SSL verification - Already enabled by default
- Use rate limiting - Respect the target server
- Monitor logs regularly - Check for suspicious activity
- Keep dependencies updated - Run
pip install --upgrade -r requirements.txt - Use virtual environments - Isolate project dependencies
- Backup your database - Regularly backup
autode_cars.db
# Check Python version
python --version # Should be 3.8+
# Check dependencies
pip list
# Reinstall dependencies
pip install --force-reinstall -r requirements.txt
# Check configuration
python -c "from config import validate_config; validate_config()"- Check internet connection
- Verify Auto.de website is accessible
- Check logs for errors:
tail -f autode_bot.log - Verify endpoint format hasn't changed
- Check rate limiting settings
- Verify bot token is correct
- Verify chat ID is correct
- Start a conversation with your bot first
- Check bot has permission to send messages
- Test with:
python -c "from common import send_telegram_message; from config import TELEGRAM_API_KEY, CHAT_ID; send_telegram_message('Test', TELEGRAM_API_KEY, CHAT_ID)"
# Check database file permissions
ls -l autode_cars.db
# Backup and reset database
mv autode_cars.db autode_cars.db.backup
# Restart bot to create new database- Adjust MAX_PAGES - Start with fewer pages (1-2) for testing
- Increase MAIN_LOOP_INTERVAL - Run less frequently in production
- Enable CHECK_ROBOTS_TXT - Respect server policies
- Monitor resource usage - Use
htoportopto check CPU/memory - Rotate logs - Use logrotate or similar tool for log management
git pull origin main
pip install --upgrade -r requirements.txt# Vacuum database to reclaim space
sqlite3 autode_cars.db "VACUUM;"
# Check database integrity
sqlite3 autode_cars.db "PRAGMA integrity_check;"- β¨ Complete security overhaul
- β¨ Added rate limiting and retry mechanisms
- β¨ Input validation and sanitization
- β¨ Modular architecture (config, common, main)
- β¨ Class-based design (AutoDEBot)
- β¨ Graceful shutdown handling
- β¨ Comprehensive error handling
- β¨ Statistics tracking
- β¨ Type hints and documentation
- β¨ Updated User-Agent
- β¨ Environment-based configuration
- β¨ robots.txt compliance check
- Initial release
- Basic scraping functionality
- Simple database storage
- Telegram notifications
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
mxyldrm
- GitHub: @mxyldrm
- Auto.de for providing the car listings platform
- Python community for excellent libraries
- Contributors and testers
This software is provided "as is" without warranty of any kind. Web scraping may be against the terms of service of some websites. Users are responsible for ensuring their use of this software complies with all applicable laws, regulations, and terms of service. The authors accept no liability for any misuse of this software.
Use responsibly and ethically.
Made with β€οΈ for educational purposes