This is a LinkedIn automation bot built with Python and Selenium that automates connection requests with personalized messages. The bot navigates LinkedIn profiles based on search criteria and sends connection requests with custom notes.
- Language: Python 3.8+
- Web Automation: Selenium WebDriver 4.22.0
- Browser: Mozilla Firefox with Geckodriver
- Logging: Python's built-in logging module
LinkedIn_Auto_Connector_Bot/
├── Linkedin_auto_connector_bot.py # Main bot script
├── requirements.txt # Python dependencies
├── geckodriver32.exe # Firefox WebDriver (Windows)
├── banner.jpg # Repository banner image
├── README.md # User documentation
├── LICENSE # MIT License
├── .gitignore # Git ignore rules
└── CLAUDE.md # This development documentation
- Function:
login_to_linkedin(driver, username, password) - Location: Linkedin_auto_connector_bot.py:47-66
- Handles LinkedIn login process
- Waits for manual CAPTCHA solving if required
- Function:
go_to_next_page(driver) - Location: Linkedin_auto_connector_bot.py:67-83
- Handles pagination through search results
- Implements scroll-down functionality
- Function:
handle_connect_button_with_retry(driver, button) - Location: Linkedin_auto_connector_bot.py:92-127
- Sends personalized connection requests
- Implements retry mechanism for failed attempts
- Handles "Add a note" workflow
- Function:
process_buttons(driver) - Location: Linkedin_auto_connector_bot.py:136-185
- Orchestrates the entire bot workflow
- Counts and limits connection requests
- Processes both "Connect" and "Follow" buttons
- Function:
refresh_page(driver, retries) - Location: Linkedin_auto_connector_bot.py:187-201
- Implements page refresh recovery mechanism
- Handles maximum retry attempts
- Hardcoded credentials in script (security risk)
- Hardcoded search URL
- Hardcoded connection message
- Fixed WebDriver paths
# .env file (to be implemented)
LINKEDIN_USERNAME=your_email@example.com
LINKEDIN_PASSWORD=your_password
SEARCH_LINK=https://www.linkedin.com/search/results/people/...
MAX_CONNECT_REQUESTS=20
FIREFOX_BINARY_PATH=/path/to/firefox
GECKODRIVER_PATH=/path/to/geckodriver- Hardcoded Credentials: Username and password are directly in the code
- No Encryption: Credentials stored in plain text
- Version Control Risk: Sensitive data could be committed to repository
- No Rate Limiting: Manual limit enforcement only
- Use environment variables for all sensitive data
- Implement proper rate limiting with daily/weekly tracking
- Add credential encryption/keyring support
- Create separate config file for non-sensitive settings
- Implement session persistence to avoid repeated logins
- Test login with valid credentials
- Test login with invalid credentials
- Test CAPTCHA handling
- Test connection request sending
- Test pagination navigation
- Test error recovery mechanisms
- Test rate limiting enforcement
- Test with different search queries
- Test on different operating systems
# Example test structure
def test_login_success():
# Mock WebDriver and test successful login
pass
def test_connection_limit():
# Test that bot stops at MAX_CONNECT_REQUESTS
pass
def test_error_recovery():
# Test retry mechanism
pass-
Environment Configuration
- Move all sensitive data to .env file
- Use python-dotenv for environment variable management
-
Error Handling
- Add comprehensive exception handling
- Implement proper logging to files
- Add screenshot capture on errors
-
Rate Limiting
- Implement database to track daily/weekly counts
- Add automatic scheduling/delays
- Create warning system near limits
-
Code Structure
- Split into multiple modules (auth, navigation, messaging)
- Create configuration class
- Implement command-line arguments
-
Features
- Add profile filtering options
- Implement message templates with variables
- Add connection acceptance monitoring
-
Cross-Platform Support
- Detect OS and adjust paths automatically
- Support multiple browsers (Chrome, Edge)
- Add Docker containerization
-
UI/UX
- Create simple GUI with tkinter
- Add progress bars
- Implement real-time statistics dashboard
-
Advanced Features
- AI-powered message personalization
- Profile analysis before connecting
- Integration with CRM systems
- Python 3.8 or higher
- Mozilla Firefox browser
- Geckodriver matching Firefox version
- pip package manager
# Clone repository
git clone https://github.com/OfficialCodeVoyage/LinkedIn_Auto_Connector_Bot.git
cd LinkedIn_Auto_Connector_Bot
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create .env file
cp .env.example .env
# Edit .env with your credentials
# Run the bot
python Linkedin_auto_connector_bot.py# requirements-dev.txt
pytest>=7.0.0
black>=22.0.0
flake8>=4.0.0
pylint>=2.0.0
python-dotenv>=0.19.0- Follow PEP 8 Python style guide
- Use meaningful variable names
- Add docstrings to all functions
- Keep functions under 20 lines when possible
- Document all configuration options
- Maintain changelog for version updates
- Keep README.md user-focused
- Use CLAUDE.md for technical documentation
- Ensure all dependencies installed
- Configure environment variables
- Test in development mode
- Run with proper logging enabled
- Consider using GitHub Actions for scheduled runs
- Implement AWS Lambda for serverless execution
- Use cloud-based browser services (Browserless, Selenium Grid)
- Basic console logging with timestamp
- Info, Warning, and Error levels
- No persistent log files
# Enhanced logging configuration
import logging
from logging.handlers import RotatingFileHandler
# Create logs directory
os.makedirs('logs', exist_ok=True)
# Configure file handler with rotation
file_handler = RotatingFileHandler(
'logs/bot.log',
maxBytes=10485760, # 10MB
backupCount=5
)
# Configure logging format
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
file_handler,
logging.StreamHandler()
]
)-
Login Fails
- Check credentials
- Verify no active CAPTCHA
- Check for account restrictions
-
WebDriver Issues
- Verify geckodriver version matches Firefox
- Check PATH configuration
- Ensure proper permissions
-
Connection Requests Fail
- Check if within weekly limits
- Verify message template format
- Check for LinkedIn UI changes
-
Script Crashes
- Check for element selector changes
- Verify network connectivity
- Review error logs
- Update Selenium and dependencies monthly
- Check for LinkedIn UI changes
- Monitor success rates
- Review and clean logs
- Update documentation
- Use semantic versioning (MAJOR.MINOR.PATCH)
- Tag releases in Git
- Maintain CHANGELOG.md
- Create release notes
- Fork the repository
- Create feature branch
- Write tests for new features
- Ensure code passes linting
- Submit pull request with description
- Use GitHub Issues
- Include error messages
- Provide reproduction steps
- Mention environment details
MIT License - See LICENSE file for details
- Author: Pavlo Bondarenko
- LinkedIn: https://www.linkedin.com/in/mrbondarenko/
- Repository: https://github.com/OfficialCodeVoyage/LinkedIn_Auto_Connector_Bot
This roadmap outlines critical improvements to transform the bot from a basic automation tool into a production-ready, secure, and scalable LinkedIn automation platform.
- Implement encrypted credential storage using keyring
- Create CredentialManager class in
config/security.py - Move all hardcoded credentials to environment variables
- Add session persistence to avoid repeated logins
- Create SQLite database for tracking connection history
- Implement daily and weekly limits
- Add automatic blocking when limits reached
- Log all connection attempts with timestamps
- Save and restore browser cookies
- Implement session timeout handling
- Reduce login frequency
LinkedIn_Auto_Connector_Bot/
├── config/
│ ├── settings.py # Configuration management
│ ├── security.py # Credential handling
│ └── constants.py # Application constants
├── modules/
│ ├── authenticator.py # Login handling
│ ├── navigator.py # Page navigation
│ ├── connector.py # Connection logic
│ ├── profile_analyzer.py # Profile analysis
│ ├── message_builder.py # Dynamic messages
│ ├── rate_limiter.py # Rate limiting
│ └── session_manager.py # Session persistence
├── utils/
│ ├── anti_detection.py # Anti-bot measures
│ ├── logger.py # Enhanced logging
│ ├── browser.py # WebDriver setup
│ └── exceptions.py # Custom exceptions
├── tests/ # Test suite
├── cli.py # Command-line interface
└── main.py # Entry point
- Implement base page class with common methods
- Create specific page classes for LinkedIn pages
- Add retry mechanisms and error handling
- Create configuration container
- Implement validation for all settings
- Support multiple configuration sources
- Use undetected-chromedriver
- Randomize user agents
- Randomize window sizes
- Override navigator properties
- Implement random delays between actions
- Add mouse movement curves (Bezier curves)
- Simulate typing with variable speed
- Add random scrolling patterns
- Occasional typos and corrections
- Implement proxy rotation
- Support authentication proxies
- Add automatic proxy health checking
- Implement relevance scoring
- Add keyword matching
- Filter by mutual connections
- Analyze profile completeness
- Create template system
- Add personalization variables
- Implement A/B testing for messages
- Track message performance
- Build search URLs programmatically
- Support multiple filter combinations
- Save search configurations
- Add Click-based command interface
- Support configuration files
- Implement progress bars
- Add statistics display
- Create Flask-based web interface
- Real-time statistics monitoring
- Configuration management UI
- Connection history viewer
- Create Dockerfile
- Add docker-compose configuration
- Support environment-based configuration
| Priority | Component | Complexity | Impact | Timeline |
|---|---|---|---|---|
| CRITICAL | Credential Security | Medium | High | Day 1-2 |
| CRITICAL | Rate Limiting | Low | High | Day 3-4 |
| HIGH | Code Modularization | High | High | Week 1 |
| HIGH | Anti-Detection | High | High | Week 2 |
| MEDIUM | Profile Analysis | Medium | Medium | Week 3 |
| MEDIUM | CLI Interface | Low | Medium | Week 3 |
| LOW | Web Dashboard | High | Low | Week 4 |
| LOW | Docker Support | Medium | Low | Week 4 |
- Security: Zero plaintext credentials, encrypted storage
- Reliability: <1% failure rate, automatic recovery
- Performance: <5s average connection time
- Detection: <0.1% account restriction rate
- Maintainability: 80%+ test coverage, modular architecture
- LinkedIn Updates: Implement selector fallbacks
- Account Restrictions: Conservative rate limits
- Detection: Multiple anti-bot measures
- Data Loss: Automatic backups and session persistence
# 1. Create new structure
mkdir -p config modules utils tests logs data sessions
# 2. Install dependencies
pip install selenium-stealth undetected-chromedriver \
python-dotenv cryptography keyring redis \
click rich flask flask-socketio pytest
# 3. Create .env from template
cp .env.example .env
# 4. Start with security module
python -c "from config.security import CredentialManager"Last Updated: September 2025 Documentation Version: 2.0.0