CLI to scrape and enrich targeted business leads from Google Search, Maps, Yelp, YellowPages, Crunchbase and directories
β¨ Features β’ β‘ Quick start β’ π§° Usage β’ π§© Architecture β’ π Roadmap β’ π€ Contributing
Freelancers, agencies and sales teams burn hours hunting prospects on Google and Maps. Commercial tools are pricey, opaque and rate-limited. LeadMine gives full control with a transparent, self-hosted CLI that pulls public data for any category and locale.
- Self-hosted & transparent β full visibility into every request, no vendor lock-in or surprise billing
- Polite by design β built-in rate limiting, random delays, user-agent rotation and stealth via Playwright
- Multi-source enrichment β Google Maps, organic Search, Yelp, YellowPages and Crunchbase with automatic website crawling for emails and missing phones
- Clean, flexible exports β deduplicated leads written to CSV, JSON, XLSX or directly to Google Sheets
|
πΊοΈ Maps Scraper Pulls name, address, phone, rating and website from Google Maps results using Playwright |
π Search Leads Extracts organic Google results and linked contact pages for broader web leads |
|
π Yelp Support Scrapes business listings from Yelp with fallback when Maps data is thin |
π¨ YellowPages & Crunchbase Additional US directory and startup ecosystem sources with profile enrichment |
|
π€ Smart Export Writes clean CSV, JSON or XLSX with configurable columns, deduplication and --append support for CSV/JSON |
π§ Contact Enricher Visits websites to discover email patterns, social links and missing phones |
|
π§ Email Verification Filters out emails from known disposable providers using a local domain list (configurable) |
β±οΈ Polite Crawling Per-source rate-limit presets (maps: 6rpm, search: 10rpm, etc.), random delays, exponential backoff on 429/blocks, user-agent rotation and stealth to reduce blocks |
|
π― Targeted Filters Category, location, rating, review count and keyword filters for high-quality leads |
π§ Local LLM Scoring Uses Ollama to score leads on relevance to your category and budget signals with configurable minScore filter (local only, no data leaves your machine) |
|
π Google Sheets Export Direct write to Google Sheets via service account (no OAuth, no extra fees) |
|
|
π Proxy Rotation + Residential Configurable proxy lists with automatic rotation; native support for residential proxy providers (Smartproxy, Oxylabs, Bright Data gateway URLs) |
|
|
πͺ Interactive Wizard Guided first-time setup that creates ~/.leadmine/config.json and runs a sample scrape |
|
|
π³ Docker Support Official image with pre-bundled Chromium β perfect for servers, CI/CD and headless deployments with zero extra setup |
Requirements: Node.js >= 18.0.0 (see engines in package.json). Ollama must be installed separately for LLM scoring. Docker is optional but recommended for server use.
npm install -g lead-mineThe CLI is available immediately as lead-mine. For local development:
git clone https://github.com/ajendras/lead-mine.git
cd lead-mine
npm install
npm run buildLeadMine ships a Dockerfile that produces a ready-to-run image based on the official Playwright Docker image. Chromium and all system dependencies are pre-bundled, eliminating download steps and making it ideal for servers, headless environments, and CI pipelines.
# Build the image (includes build step via prepare script)
npm run docker:build
# or
docker build -t lead-mine .Usage examples
# Interactive wizard (recommended first run)
docker run -it --rm lead-mine wizard
# Standard scrape with output mounted to host
docker run --rm \
-v $(pwd):/data \
-v ~/.leadmine:/root/.leadmine \
lead-mine scrape \
--category="plumbers" \
--location="Portland, OR" \
--limit=30 \
--output=/data/leads.csv \
--enrich \
--verify-emails
# Search source with LLM scoring (Ollama must be available on host; use --network=host if needed)
docker run --rm \
-v $(pwd):/data \
-v ~/.leadmine:/root/.leadmine \
lead-mine scrape \
--source=search \
--query="HVAC companies near Austin TX" \
--output=/data/results.csv \
--enrich \
--use-llm-scoringNotes
- The image automatically skips Playwright browser downloads.
- Mount
~/.leadmineto persist configuration, service-account keys, and cached data. - For Ollama scoring inside Docker, run Ollama on the host and add
--network=host(or link containers). - The entrypoint is the
lead-minebinary; any CLI command works. - Image size is ~1.2 GB (Playwright base); extend it for custom needs.
Run the interactive wizard (recommended for first-time users):
lead-mine wizardIt will ask a few questions, create a config file with your preferences, and run a sample scrape so you can see results immediately.
import { loadConfig, scrapeMaps, scrapeYellowPages, saveLeads, exportToSheets, RATE_LIMIT_PRESETS } from 'lead-mine';
const config = await loadConfig();
// Config values are merged; explicit options override them
const leads = await scrapeYellowPages('plumbers', 'Portland, OR', {
...config,
limit: 30,
enrich: true,
verifyEmails: true,
useLLMScoring: true,
ollamaModel: 'llama3.1',
rpm: 12,
proxy: 'http://user:pass@residential.provider:22222',
});
await saveLeads(leads, 'leads.csv');
// or export directly to Sheets
// await exportToSheets(leads, '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms');
console.log(`Captured ${leads.length} leads`);Interactive Wizard (recommended for first-time users)
lead-mine wizardThe wizard guides you through choosing a default source, category, location, enrichment settings and more. It creates ~/.leadmine/config.json and runs a sample scrape so you can see results right away.
Run the CLI (most common workflow). The CLI automatically loads defaults from ~/.leadmine/config.json if it exists. Flags override config values.
lead-mine scrape --category="plumbers" --location="Portland, OR" --limit=30 --output=leads.csv --verify-emailsSearch-focused run with enrichment:
lead-mine scrape --source=search --query="HVAC companies near Austin TX" --output=results.json --enrich --verify-emailsLLM scoring (requires Ollama running locally with a model pulled):
lead-mine scrape --category="plumbers" --location="Portland, OR" --use-llm-scoring --ollama-model=llama3.1 --min-score=6 --limit=15Yelp fallback when Maps coverage is thin:
lead-mine scrape --source=yelp --category="roof repair" --location="Seattle, WA" --limit=15YellowPages and Crunchbase examples:
lead-mine scrape --source=yellowpages --category="electricians" --location="Chicago, IL" --limit=25
lead-mine scrape --source=crunchbase --query="fintech startups" --limit=15 --enrich --verify-emailsGoogle Sheets direct export (see setup below):
lead-mine scrape --category="plumbers" --location="Portland, OR" \
--sheets=1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms --limit=20 --enrichResidential proxy example (rotates IPs via provider gateway):
lead-mine scrape --category="lawyers" --location="New York, NY" --limit=50 \
--proxy="http://youruser-zone-residential:yourpass@gate.smartproxy.com:7000"Multiple proxies (CLI rotates through them):
lead-mine scrape --category="plumbers" --location="Portland, OR" \
--proxy http://proxy1.example.com:8080 http://proxy2.example.com:8080Rate-limit override (uses preset for source otherwise):
lead-mine scrape --category="plumbers" --location="Portland, OR" --rpm=8Append mode (CSV/JSON only)
lead-mine scrape --category="plumbers" --location="Portland, OR" --output=leads.csv --appendDocker usage (see Docker section above for full details):
docker run --rm \
-v $(pwd):/data \
-v ~/.leadmine:/root/.leadmine \
lead-mine scrape --category="plumbers" --location="Portland, OR" --output=/data/leads.csv --enrichProgrammatic usage with custom options (see src/index.ts):
import { loadConfig, scrapeYellowPages, scrapeCrunchbase, saveLeads, exportToSheets, scoreLeadWithOllama, withRateLimit, randomDelay, processWithConcurrency, RATE_LIMIT_PRESETS } from 'lead-mine';
const config = await loadConfig();
const leads = await scrapeYellowPages('coffee shops', 'Portland, OR', {
...config,
limit: 25,
minRating: 4.0,
minScore: 6,
enrich: true,
verifyEmails: true,
useLLMScoring: true,
ollamaModel: 'llama3.1',
proxy: ['http://proxy1:8080', 'http://proxy2:8080'],
concurrency: 3,
});
await saveLeads(leads, 'coffee-leads.csv');
// append example:
await saveLeads(leads, 'coffee-leads.csv', true);
// or
// await exportToSheets(leads, 'your-spreadsheet-id-here', { sheetName: 'PortlandLeads' });
console.log(`Captured ${leads.length} leads`);Advanced: custom rate-limit and headless control
import { loadConfig, scrapeCrunchbase, processWithConcurrency, RATE_LIMIT_PRESETS } from 'lead-mine';
const config = await loadConfig();
const leads = await scrapeCrunchbase('AI companies', {
...config,
limit: 20,
headless: false,
enrich: true,
verifyEmails: true,
useLLMScoring: true,
concurrency: 4,
});
// Example of direct parallel processing of custom items using preset
const processed = await processWithConcurrency(
leads,
async (lead) => {
// custom per-lead logic
return lead;
},
3,
{ source: 'crunchbase' } // or RATE_LIMIT_PRESETS.crunchbase.rpm
);Ollama Setup for LLM Scoring
- Install Ollama from https://ollama.com
- Start the server:
ollama serve - Pull a model:
ollama pull llama3.1(ormistral,phi3,gemma2:9b) - Use
--use-llm-scoring(or setuseLLMScoring: truein config). Scoring is rate-limited and runs locally.
Configuration File
The easiest way to create your configuration is by running lead-mine wizard. It will interactively ask questions and write a ready-to-use ~/.leadmine/config.json.
LeadMine automatically loads defaults from ~/.leadmine/config.json (created manually or via the wizard). Any ScrapeOptions (including source, category and location) can be set here. Command-line flags and programmatic options take precedence. If rpm is omitted, a polite preset for the chosen source is used automatically.
Example ~/.leadmine/config.json:
{
"source": "maps",
"category": "plumbers",
"location": "Portland, OR",
"limit": 30,
"enrich": true,
"verifyEmails": true,
"useLLMScoring": true,
"ollamaModel": "llama3.1",
"headless": true,
"minRating": 4.0,
"minScore": 5.0,
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
"proxy": "http://user:pass@zproxy.lumproxy.com:22222",
"googleSheets": {
"spreadsheetId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
"sheetName": "Leads"
}
}| Option | Default | Description |
|---|---|---|
| source | maps | Default scraper source (maps, search, yelp, yellowpages, crunchbase) |
| category | β | Default business category or search term |
| location | Portland, OR | Default geographic location for directory scrapers |
| limit | 20 | Maximum number of leads to return (ScrapeOptionsSchema) |
| enrich | true | Visit websites to discover emails and metadata |
| verifyEmails | false | Filter extracted emails against a local list of known disposable domains; sets emailVerified on Lead records |
| useLLMScoring | false | Enable local LLM scoring via Ollama for relevance (to target) and budget signals |
| ollamaModel | llama3.1 | Ollama model name (must be pulled locally; llama3.1, mistral, phi3 supported) |
| headless | true | Run browser without GUI (--no-headless to disable) |
| rpm | varies by source | Requests per minute. Each source has a polite preset (maps: 6, search: 10, yelp: 15, yellowpages: 25, crunchbase: 12). Overridable via flag/config. Exponential backoff is applied automatically on rate-limit or block errors. |
| minRating | β | Filter leads by minimum rating (0β5) |
| minScore | 0 | Minimum relevance score (0-10) to keep after LLM scoring (only applied if useLLMScoring: true) |
| userAgent | β | Override default stealth user agent |
| proxy | β | Single proxy URL or array of URLs for rotation. Residential proxies supported via provider gateway (e.g. http://user-zone-resi:pass@gate.smartproxy.com:7000). Rotates automatically across browser sessions. |
| googleSheets.spreadsheetId | β | Spreadsheet ID for direct Google Sheets export |
| googleSheets.sheetName | Leads | Target sheet/tab name inside the spreadsheet |
| googleSheets.serviceAccountKeyPath | ~/.leadmine/service-account.json | Path to service account JSON key file |
| concurrency | 3 | Max parallel operations for enrichment/scoring (used by processWithConcurrency) |
| append | false | Append leads to existing CSV/JSON file (instead of overwriting). Other formats always overwrite. |
RateLimitOptions (used by withRateLimit, processWithConcurrency and internally by all scrapers) can be supplied as a plain number (treated as RPM) or an object:
{
rpm?: number; // requests per minute
backoffFactor?: number; // multiplier on 429 errors (default 1.5)
maxDelayMs?: number; // cap on backoff delay (default 45000)
source?: ScrapeSource; // used for independent per-source timers
}All options are validated by ScrapeOptionsSchema (Zod) in src/types.ts.
When using the Docker image, the same config file is loaded from the mounted ~/.leadmine (or /root/.leadmine) volume.
- Go to the Google Cloud Console, create/select a project.
- Enable the Google Sheets API under APIs & Services > Library.
- Navigate to IAM & Admin > Service Accounts > Create Service Account.
- Grant the Editor role, then create a key (JSON format) and download it.
- Copy the downloaded JSON to
~/.leadmine/service-account.json(or setgoogleSheets.serviceAccountKeyPath). - Open your target Google Sheet β Share β add the
client_emailvalue from the JSON file (ends in@gserviceaccount.com) with Editor permissions.
LeadMine will now write leads directly to the sheet using the service account (no user login required). The first row becomes a header; existing data is overwritten.
flowchart TD
CLI[cli.ts<br>Commander.js flags] --> Index[src/index.ts<br>orchestrator]
Index --> Maps[src/scrapers/maps.ts<br>Playwright scroll + panel extraction]
Index --> Search[src/scrapers/search.ts<br>organic results + snippet parsing]
Index --> Yelp[src/scrapers/yelp.ts<br>list + detail page visits]
Index --> YellowPages[src/scrapers/yellowpages.ts<br>list extraction with stable classes]
Index --> Crunchbase[src/scrapers/crunchbase.ts<br>profile scraping + website extraction]
Maps & Search & Yelp & YellowPages & Crunchbase --> Throttle[src/utils/throttle.ts<br>randomDelay + withRateLimit (presets + backoff)]
Index --> Enrich[enricher.ts<br>launchStealthBrowser + regex extraction + disposable checker + Ollama scoring]
Enrich --> Browser[src/utils/browser.ts<br>stealth Chromium + proxy rotator]
Index --> Dedup[deduplicateLeads<br>name+address+website key]
Index --> Parallel[processWithConcurrency<br>respects concurrency limit via batches]
Dedup --> Export[exporter.ts<br>csv-writer / xlsx / JSON / Google Sheets API]
Export --> FS[CSV / JSON / XLSX output]
Export --> Google[Google Sheets via service account (googleapis)]
style Index fill:#d9c2a3,stroke:#3f2a1e
src/index.ts coordinates scraping, enrichment, deduplication and export. All scrapers return a uniform Lead[] shape defined in src/types.ts. Browser sessions are created fresh per scrape/enrichment to maintain stealth. Proxy rotation (including residential gateways) is handled centrally in browser.ts.
.
βββ src/
β βββ index.ts # Public API: scrapeMaps(), scrapeSearch(), scrapeYelp(), scrapeYellowPages(), scrapeCrunchbase(), saveLeads(), exportToSheets(), loadConfig(), saveConfig(), scoreLeadWithOllama(), withRateLimit(), processWithConcurrency(), RATE_LIMIT_PRESETS
β βββ cli.ts # Commander.js command definition with all flags + interactive wizard
β βββ config.ts # loadConfig(), saveConfig() + CONFIG_PATH/SERVICE_ACCOUNT_PATH for ~/.leadmine/
β βββ types.ts # Lead interface, ScrapeOptions (incl. googleSheets), RateLimitPreset + RATE_LIMIT_PRESETS, Zod schema, ExportFormat
β βββ enricher.ts # enrichLead() + extractEnrichedInfo (mailto, regex, tel:) + isDisposableEmail() + scoreLeadWithOllama()
β βββ exporter.ts # exportLeads() + new exportToSheets() using googleapis
β βββ scrapers/
β β βββ maps.ts # scrapeGoogleMaps() + extractFromSidePanel
β β βββ search.ts # scrapeGoogleSearch() + extractContactInfo
β β βββ yelp.ts # scrapeYelp() + extractYelpDetail
β β βββ yellowpages.ts # scrapeYellowPages() + extractYellowPagesResults
β β βββ crunchbase.ts # scrapeCrunchbase() + extractCrunchbaseResults/Profile
β βββ utils/
β βββ browser.ts # launchStealthBrowser() + setProxies() + rotation
β βββ throttle.ts # randomDelay(), withRateLimit() (now with presets + backoff)
βββ tests/
β βββ scrapers.test.ts # Vitest mocks + fixture tests for parsers, dedup, export, sheets
βββ playwright.config.ts # Headless config, user-agent, timeouts
βββ tsconfig.json
βββ Dockerfile # Official image with bundled Chromium (Playwright base)
βββ package.json # bin:"lead-mine", scripts, dependencies
npm testRuns the Vitest suite in tests/scrapers.test.ts. Covers mocked scraper fixtures, Lead shape validation, deduplication logic, enrichment fallbacks, throttle utilities (randomDelay, withRateLimit with presets and backoff), export formats (CSV/JSON/XLSX), the new exportToSheets() path (including error cases for missing service account key), CLI option parsing, the loadConfig()/saveConfig() helpers, new proxy rotation behaviour, the YellowPages/Crunchbase parsers, the new disposable email verification logic, local LLM scoring with mocked Ollama responses, the interactive wizard, processWithConcurrency (respects concurrency limit and calls rate limiter), and append mode for CSV/JSON.
- v0.1.0 β first release: Maps Scraper, Search Leads, Yelp Support, Smart Export
- Add configuration file support (~/.leadmine/config.json)
- Implement proxy rotation and residential proxy interface
- Add more directory scrapers (YellowPages, Crunchbase)
- Email verification step using disposable checker or SMTP
- Interactive wizard mode for first-time users
- Google Sheets direct export via service account
- Local LLM lead scoring with Ollama (relevance, budget signals)
- Parallel browser contexts with worker pool
- HTML report generator with embedded map previews
- Docker image with bundled Chromium for server use
- CRM import templates (HubSpot CSV, Salesforce)
- Rate-limit presets per source with exponential backoff
- Add --append flag to saveLeads() allowing CSV/JSON append instead of overwrite
- Implement configurable minScore threshold in ScrapeOptions to filter LLM-scored leads
- Add actionable troubleshooting suggestions to CLI error output (blocks, missing Ollama, proxy failures)
- Expand scrapers.test.ts with mocked end-to-end tests for wizard + config roundtrip
- Document scraper extension pattern and template in CONTRIBUTING.md with new source checklist
- Support loading proxy list from text file (--proxy-file) in config.ts and browser utils
- Add --dry-run mode that prints planned queries, limits and estimated cost without launching browsers
- Update Docker image with multi-stage build and non-root user for smaller size and security
π€ This roadmap is worked through continuously β ideas and PRs welcome!
Contributions are welcome! Please read CONTRIBUTING.md and follow our Code of Conduct. Good-first-issue PRs around new directory sources, improved enrichment patterns, or additional export columns are especially appreciated.
MIT Β© ajendras. See LICENSE for details.