A sophisticated tool for identifying and verifying social media profiles, email addresses, and phone numbers for NCAA athletes with high accuracy.
- Comprehensive Contact Discovery: Finds social media profiles (Twitter, Facebook, Instagram), email addresses, and phone numbers
- Multi-Platform Authentication: Robust login system for accessing restricted content on social media platforms
- Cookie Consent Handling: Automatically manages cookie consent dialogs across different platforms
- Session Persistence: Maintains login sessions throughout the scraping process with automatic re-login
- Profile Verification: Uses multiple verification signals to ensure correct athlete identification
- AI-Powered Analysis: Enhanced verification using OpenAI models for accurate profile matching
- Active Learning: Self-improving system that gets more accurate over time
- Vision Verification: Optional image-based verification of social media profiles
- Enhanced URL Validation: Filters out generic pages and invalid endpoints
-
Clone the repository:
git clone <repository-url> cd ncaascraper
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r src/requirements.txt
-
Set up environment variables:
Create a
.envfile in the project root with your API keys and social media credentials:# API Keys OPENAI_API_KEY=your_openai_api_key_here # Social Media Credentials (required for authentication) FACEBOOK_EMAIL=your_facebook_email FACEBOOK_PASSWORD=your_facebook_password INSTAGRAM_USERNAME=your_instagram_username INSTAGRAM_PASSWORD=your_instagram_password TWITTER_EMAIL=your_twitter_email TWITTER_USERNAME=your_twitter_username TWITTER_PASSWORD=your_twitter_password
Run the scraper with default settings:
python src/main.pyThis will:
- Read athlete data from
src/data/input/test_players.xlsx - Output results to
src/data/output/athletes_updated.xlsx - Use basic verification methods (no AI)
| Argument | Description | Default |
|---|---|---|
--input |
Path to input Excel file | src/data/input/test_players.xlsx |
--output |
Path to output Excel file | src/data/output/athletes_updated.xlsx |
--openai-api-key |
OpenAI API key (can also be set in .env file) |
None |
--ai-verification |
Enable AI verification for profile matching | False |
--ai-model |
OpenAI model to use for reasoning | gpt-4o |
--search-query-model |
OpenAI model to use for search query generation | gpt-4o |
--vision-model |
OpenAI model to use for vision verification | gpt-4o |
--vision-enabled |
Enable vision verification for social media profiles | False |
--active-learning |
Enable active learning to improve results over time | False |
--timeout |
Timeout per athlete in seconds | 45 |
python src/main.py --input data/input/my_athletes.xlsx --output data/output/results.xlsxpython src/main.py --ai-verificationpython src/main.py --ai-verification --active-learning --vision-enabled --timeout 60python src/main.py --ai-verification --ai-model gpt-4o --search-query-model gpt-4o --timeout 90python src/main.py --ai-verification --vision-enabled --vision-model gpt-4o --timeout 60python src/main.py --input data/input/large_dataset.xlsx --output data/output/large_results.xlsx --timeout 120Note: The
--timeoutparameter always requires a numeric value (in seconds). For example,--timeout 60sets a 60-second timeout per athlete.
The input Excel file should contain at minimum:
First_NameLast_Name
Optional additional columns that improve accuracy:
SportSchoolPositionYearState
The enhanced social media authentication system:
- Robust Login Flow: Automatically logs into Twitter, Facebook, and Instagram with comprehensive error handling
- Cookie Consent Management: Intelligently handles various cookie consent dialogs across platforms
- Session Verification: Verifies login status before and during scraping to ensure continuous access
- Auto Re-login: Detects when sessions expire and automatically re-authenticates
- Extended Verification: Uses multiple signals to confirm successful authentication
- Debugging Support: Captures screenshots for troubleshooting authentication issues
This system ensures reliable access to restricted content, improving the quality and quantity of data collected.
The URL validation system:
- Filters out generic social media pages that aren't athlete profiles
- Validates endpoints to ensure they're actual profile pages
- Uses platform-specific patterns to identify genuine profiles
- Analyzes URL content to detect athlete-related indicators
- Improves accuracy by reducing false positives from generic pages
- Performs real-time validation during the scraping process
The AI verification feature uses OpenAI's models to:
- Generate optimized search queries based on athlete information
- Analyze search results to identify potential profiles and contact information
- Verify profiles through multi-stage verification:
- NCAA status determination (Is this an NCAA player at all?)
- Specific athlete matching (Is this the correct NCAA player?)
- Disqualifying evidence check (Is there anything that rules this out?)
- Contact information validation (Is this email/phone likely to belong to the athlete?)
- Provide detailed reasoning and confidence scores for each match
The active learning system:
- Records verification results and search query effectiveness
- Adapts confidence thresholds based on feedback
- Improves search queries based on past successes
- Implements pattern recognition for similar athletes
- Gets more accurate over time as it processes more athletes
When enabled, the vision verification feature:
- Captures screenshots of social media profiles
- Uses AI vision models (gpt-4o) to analyze profile images
- Looks for visual evidence connecting the profile to the athlete
- Integrates visual analysis with text-based verification
Note: The vision verification feature now uses the gpt-4o model, which has built-in vision capabilities, replacing the deprecated gpt-4-vision-preview model.
- Use the
--ai-verificationflag for maximum accuracy - Enable
--active-learningfor long-term improvements - Set appropriate
--timeoutvalues based on your dataset size - Store your OpenAI API key in the
.envfile rather than passing it as a command-line argument - For critical applications, enable
--vision-enabledfor additional verification - Set up social media authentication to access restricted profiles and improve results
- Use a dedicated social media account for scraping to avoid account restrictions
The project is organized into several key components:
ncaascraper/
├── src/
│ ├── main.py # Main entry point
│ ├── requirements.txt # Dependencies
│ ├── components/ # Core components
│ │ ├── ai_verifier.py # AI verification logic
│ │ ├── active_learning.py # Learning system
│ │ └── profile_verifier.py # Profile verification
│ ├── services/ # Service layer
│ │ ├── scraper_service.py # Basic scraper
│ │ └── enhanced_scraper_service.py # AI-enhanced scraper
│ └── utils/ # Utilities
│ ├── driver.py # Browser automation
│ ├── social_media_auth.py # Authentication system
│ ├── url_validator.py # URL validation
│ └── logger.py # Logging system
├── data/ # Data storage
│ ├── input/ # Input files
│ ├── output/ # Results
│ ├── logs/ # Log files
│ ├── screenshots/ # Profile screenshots
│ ├── cache/ # Cache storage
│ └── chrome_data/ # Browser session data
└── .env # Environment variables
- If social media authentication fails, check your credentials in the
.envfile - For cookie consent issues, try running with a fresh Chrome profile by deleting the
data/chrome_datadirectory - If you see "session expired" errors, the system will attempt to re-login automatically
- For persistent login issues, check if the platform has implemented new security measures
- If you encounter timeout errors, increase the
--timeoutvalue - For slow performance, ensure you have a stable internet connection
- Consider running with fewer AI features if processing speed is critical
- Ensure your input Excel file has the required columns
- Check that your OpenAI API key is valid and has sufficient quota
- For vision verification issues, ensure Chrome is properly installed
- If you're getting low-confidence matches, try enabling more verification features
- For URL validation problems, check the logs for specific error messages
- If the Chrome driver fails to start, ensure you have Chrome installed and updated
- For package dependency issues, try reinstalling with
pip install -r src/requirements.txt --force-reinstall