A high-performance YouTube influencer scraper designed to collect data on 10,000+ YouTube channels across multiple categories, cities, and countries. Features automatic API key rotation, comprehensive data extraction, and efficient CSV export.
- ๐ Auto-Rotating API Keys: Supports up to 20 YouTube Data API v3 keys for maximum throughput
- ๐ Global Coverage: Scrapes influencers from 50+ cities across 15+ countries
- ๐ท๏ธ Multi-Category Support: 50+ categories including beauty, tech, gaming, fitness, food, travel, and more
- ๐ Rich Data Extraction: Subscriber count, view count, video count, engagement rate, category, location, and more
- ๐พ Checkpoint System: Automatic progress saving every 1000 influencers
- โก Rate Limiting: Intelligent API quota management and rate limiting
- ๐ Comprehensive Logging: Detailed logging with file and console output
- ๐ Error Handling: Robust error handling with automatic retries
pip install -r requirements.txtEdit config.py and add your YouTube Data API v3 keys:
YOUTUBE_API_KEYS = [
"AIzaSyB...", # Your API key 1
"AIzaSyC...", # Your API key 2
"AIzaSyD...", # Your API key 3
# ... add up to 20 keys
]๐ก How to get YouTube API keys:
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable YouTube Data API v3
- Create credentials (API Key)
- Repeat for multiple keys
python test_scraper.pypython mass_scraper.pymass-scrapper/
โโโ youtube_scraper.py # Core scraper class with API key rotation
โโโ mass_scraper.py # Main mass scraping script
โโโ config.py # Configuration and API keys
โโโ test_scraper.py # Test script for verification
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ output/ # Generated CSV files (auto-created)
โโโ youtube_influencers_10000.csv
โโโ checkpoint_1000_influencers.csv
โโโ checkpoint_2000_influencers.csv
- Number of Keys: Supports 1-20 API keys
- Quota Management: Automatic rotation when quota exceeded
- Reset Time: Quota resets after 1 hour
SCRAPING_CONFIG = {
'max_results_per_search': 50, # Max results per search
'min_subscribers': 1000, # Minimum subscriber count
'rate_limit_delay': 0.1, # Delay between API calls
'checkpoint_interval': 1000, # Save progress every N influencers
}OUTPUT_CONFIG = {
'csv_encoding': 'utf-8',
'include_timestamp': True,
'max_description_length': 500,
}Each scraped influencer includes:
| Field | Description | Example |
|---|---|---|
channel_id |
YouTube channel ID | UC1234567890 |
channel_title |
Channel name | Tech Guru Mumbai |
description |
Channel description | Latest tech reviews and tutorials... |
subscriber_count |
Number of subscribers | 125000 |
view_count |
Total view count | 25000000 |
video_count |
Number of videos | 450 |
published_at |
Channel creation date | 2020-01-15T10:30:00Z |
category |
Content category | Technology & Gadgets |
city |
City location | Mumbai |
country |
Country location | India |
niche |
Content niche | tech |
engagement_rate |
Calculated engagement | 5.2 |
search_query |
Search terms used | Mumbai tech |
scraped_at |
Scraping timestamp | 2024-01-15T14:30:00 |
- ๐ฎ๐ณ India: Mumbai, Delhi, Bangalore, Chennai, Hyderabad, Kolkata
- ๐บ๐ธ USA: LA, NYC, San Francisco, Chicago, Houston, Phoenix
- ๐ฌ๐ง UK: London, Manchester, Birmingham, Leeds, Liverpool
- ๐ซ๐ท France: Paris, Marseille, Lyon
- ๐ฉ๐ช Germany: Berlin, Hamburg, Munich
- ๐ฎ๐น Italy: Milan, Rome
- ๐ฏ๐ต Japan: Tokyo, Osaka, Yokohama
- ๐ฆ๐บ Australia: Sydney, Melbourne, Brisbane
- ๐จ๐ฆ Canada: Toronto, Montreal, Vancouver
- Beauty & Fashion: makeup, skincare, fashion, beauty
- Technology: tech, programming, gadgets, AI
- Gaming: gaming, esports, streaming
- Fitness & Health: fitness, yoga, nutrition, wellness
- Food & Cooking: food, cooking, baking, restaurants
- Travel & Lifestyle: travel, lifestyle, vlogs
- Education: education, tutorials, courses
- Business & Finance: business, finance, entrepreneurship
- Music & Arts: music, art, dance
- Sports: sports, athletics, workout
- Automotive: cars, bikes, automotive
- Parenting: parenting, family, kids
- Science: science, research, innovation
- Entertainment: comedy, entertainment, funny
- DIY & Crafts: diy, crafts, hacks
- Reviews: reviews, testing, unboxing
- Target: 10,000+ influencers
- Rate: ~500-1000 influencers/hour (with 20 API keys)
- Duration: 10-20 hours for full scrape
- Storage: ~50-100MB CSV files
- Quota per key: 10,000 units/day
- Search request: 100 units
- Channel request: 1 unit
- With 20 keys: 200,000 units/day total
from youtube_scraper import YouTubeInfluencerScraper
# Initialize with multiple API keys
api_keys = ["key1", "key2", "key3"]
scraper = YouTubeInfluencerScraper(api_keys)
# Search for channels
channels = scraper.search_channels("Mumbai", "tech", max_results=10)
# Get channel statistics
for channel in channels:
stats = scraper.get_channel_statistics(channel['channelId'])
print(f"{stats['channelTitle']}: {stats['subscriberCount']} subscribers")
scraper.close()# Modify search configs in mass_scraper.py
custom_configs = [
{"category": "your_category", "cities": ["Your City"]},
# Add more custom combinations
]- Console: Real-time progress updates
- File:
youtube_scraper.log(detailed logging) - Checkpoints: Progress saved every 1000 influencers
๐ท๏ธ Processing category: tech
Cities: Mumbai, Delhi, Bangalore, Chennai, New York, San Francisco, London, Tokyo, Berlin
๐ Scraping tech influencers in Mumbai...
โ
Found 45 channels
โ
Added: Tech Guru Mumbai (125,000 subscribers)
๐ Progress: 1,245/10,000 influencers collected
๐ Searches completed: 89
โฑ๏ธ Rate: 847.2 influencers/hour
๐ Active API keys: 18/20
- YouTube API has strict rate limits
- Each API key: 10,000 units/day
- Search requests: 100 units each
- Channel requests: 1 unit each
- Use multiple API keys for higher throughput
- Don't exceed rate limits to avoid temporary bans
- Monitor quota usage through logs
- Use checkpoints for long-running scrapes
- Respect YouTube's terms of service
- This tool is for educational/research purposes
- Respect YouTube's Terms of Service
- Don't scrape data for commercial use without permission
- Be mindful of rate limits and API quotas
-
API Key Errors
- Verify API keys are valid and have YouTube Data API v3 enabled
- Check quota limits in Google Cloud Console
-
No Results Found
- Try different city/category combinations
- Check if search terms are too specific
-
Rate Limiting
- Add more API keys
- Increase delays between requests
- Wait for quota reset (1 hour)
-
Memory Issues
- Reduce batch sizes
- Use checkpoints more frequently
Enable debug logging in config.py:
LOGGING_CONFIG = {
'level': 'DEBUG', # Change from 'INFO' to 'DEBUG'
# ... other settings
}- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is for educational purposes. Please respect YouTube's Terms of Service and use responsibly.
If you encounter issues:
- Check the logs for error messages
- Verify API key configuration
- Test with the test script first
- Check YouTube API quota status
- Database storage support (MySQL, PostgreSQL)
- Proxy rotation for IP diversity
- Advanced filtering and sorting
- Real-time monitoring dashboard
- Export to multiple formats (JSON, Excel)
- Scheduled scraping with cron jobs
- Multi-threading support
- Advanced analytics and insights
Happy Scraping! ๐