A powerful and efficient tool to scrape business leads from Google Maps. Extract business names, phone numbers, addresses, websites, ratings, and more with ease.
- ✅ Async Web Scraping: Uses Playwright for fast, reliable browser automation
- ✅ Flexible Filtering: Filter leads by rating, website availability, category, and phone numbers
- ✅ Multiple Export Formats: Export results as CSV, JSON, or both
- ✅ CLI Interface: Simple command-line interface with powerful options
- ✅ Configuration Management: YAML-based configuration for default settings
- ✅ Comprehensive Logging: Track all operations with detailed logs
- ✅ Production Ready: Error handling, async support, and clean architecture
- Python 3.8 or higher
- pip package manager
- Clone or Download the Project
cd maps-lead-scraper- Create a Virtual Environment (Recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install Dependencies
pip install -r requirements.txt- Install Playwright Browsers
playwright install chromiumpython main.py --query "dentist" --city "Lucknow"# Filter by minimum rating
python main.py --query "restaurant" --city "Delhi" --min-rating 4.0
# Filter for businesses without websites
python main.py --query "plumber" --city "Mumbai" --filter-no-website
# Filter for businesses with phone numbers
python main.py --query "accountant" --city "Bangalore" --has-phone# Export as JSON
python main.py --query "dentist" --city "Lucknow" --format json
# Export as both CSV and JSON
python main.py --query "dentist" --city "Lucknow" --format both
# Custom output filename
python main.py --query "dentist" --city "Lucknow" --output my_leads# Set custom output directory
python main.py --query "dentist" --city "Lucknow" --output-dir ./results
# Limit maximum results
python main.py --query "dentist" --city "Lucknow" --max-results 100
# Detailed scrape (slower but more accurate)
python main.py --query "dentist" --city "Lucknow" --detailed
# Print results without saving to file
python main.py --query "dentist" --city "Lucknow" --no-export
# Combine multiple filters
python main.py --query "dentist" --city "Lucknow" \
--filter-no-website --min-rating 3.5 --format json --output results| Argument | Type | Required | Description |
|---|---|---|---|
--query |
string | ✅ | Search query (e.g., "dentist", "restaurant") |
--city |
string | ✅ | City name (e.g., "Lucknow", "Delhi") |
--format |
csv/json/both | ❌ | Export format (default: csv) |
--output |
string | ❌ | Output filename (default: leads) |
--filter-no-website |
flag | ❌ | Keep only businesses without websites |
--min-rating |
float | ❌ | Minimum rating threshold (0-5) |
--category |
string | ❌ | Filter by category keyword |
--has-phone |
flag | ❌ | Keep only leads with phone numbers |
--max-results |
int | ❌ | Maximum results to scrape |
--output-dir |
string | ❌ | Output directory (default: outputs) |
--detailed |
flag | ❌ | Perform detailed scrape |
--no-export |
flag | ❌ | Skip exporting to files |
Edit config.yaml to set default values:
# Browser settings
headless: true # Run browser in headless mode
scroll_pause: 2 # Pause between scrolls (seconds)
max_results: 50 # Default maximum results
# Export settings
output_dir: outputs # Default output directoryname,phone,address,website,rating,category
ABC Dental Clinic,+91-522-1234567,123 Main St Lucknow,https://example.com,4.5,Dentist
XYZ Dental Care,N/A,456 Park Ave Lucknow,N/A,4.2,Dentist
[
{
"name": "ABC Dental Clinic",
"phone": "+91-522-1234567",
"address": "123 Main St Lucknow",
"website": "https://example.com",
"rating": 4.5,
"category": "Dentist"
},
{
"name": "XYZ Dental Care",
"phone": "N/A",
"address": "456 Park Ave Lucknow",
"website": "N/A",
"rating": 4.2,
"category": "Dentist"
}
]maps-lead-scraper/
├── scraper/
│ ├── __init__.py # Package initialization
│ ├── maps.py # Google Maps scraper
│ ├── filters.py # Lead filtering functions
│ └── exporter.py # CSV/JSON export functionality
├── main.py # CLI entry point
├── config.yaml # Configuration file
├── requirements.txt # Python dependencies
├── README.md # This file
├── outputs/ # Exported leads directory
└── scraper.log # Application logs
Handles web scraping of Google Maps using Playwright.
Main Methods:
scrape(keyword, city, max_results)- Basic scrapingscrape_detailed(keyword, city, max_results)- Detailed scraping with more information
Provides filtering capabilities for leads.
Available Filters:
filter_no_website(leads)- Find businesses without websitesfilter_by_rating(leads, min_rating)- Filter by minimum ratingfilter_by_category(leads, category_keyword)- Filter by categoryfilter_by_name(leads, name_keyword)- Filter by namefilter_has_phone(leads)- Keep only leads with phone numbersapply_filters(leads, **kwargs)- Apply multiple filters at once
Handles exporting leads to various formats.
Available Formats:
export_csv(leads, filename, output_dir)- Export to CSVexport_json(leads, filename, output_dir)- Export to JSONexport_both(leads, filename, output_dir)- Export to both formats
The application creates a scraper.log file with detailed logs of all operations. Check this file to troubleshoot issues.
- Adjust scroll_pause: Increase if the website loads slowly, decrease for faster scraping
- Use max_results: Set a reasonable limit to avoid unnecessary scraping
- Filter early: Apply filters after scraping to reduce data processing
- Headless Mode: Keep
headless: truefor faster performance
The scraper includes comprehensive error handling:
- Connection timeouts and retries
- Invalid filter parameters validation
- File I/O error recovery
- Graceful interruption with Ctrl+C
- Results depend on Google Maps UI structure (may need updates if Google changes the page)
- Respects rate limiting and doesn't bypass Google's terms of service
- Website extraction may be limited due to page structure changes
MIT License - See LICENSE file for details
Contributions are welcome! Feel free to:
- Report bugs and issues
- Suggest new features
- Improve documentation
- Submit pull requests
This tool is for educational and commercial use. Ensure you comply with:
- Google Maps Terms of Service
- Local laws and regulations regarding web scraping
- Website's robots.txt and terms of service
- Rate limiting and responsible use practices
For issues, questions, or suggestions:
- Check the logs in
scraper.log - Review the documentation above
- Verify your internet connection and Google Maps accessibility
- Ensure Playwright browsers are installed (
playwright install)
- Initial release
- Core scraping functionality
- CSV and JSON export
- Advanced filtering options
- CLI interface
- Configuration management
Made with ❤️ for lead generation and business intelligence