Skip to main content

Lead generation tool using Google Places API with ZIP code optimization

Project description

PyLeadFinder

Find and enrich business leads using Google Places API with ZIP code optimization. Optionally includes email extraction via website scraping.

Installation

pip install pyleadfinder

Requirements:

  • Python 3.9+
  • Google Places API key (get one)

Usage

PyLeadFinder supports three operating modes:

1. API Mode (Default) - For Integration

Returns JSON-serializable dictionaries directly.

from pyleadfinder import leadfinder

results = leadfinder(
    places_api_key="YOUR_KEY",
    queries=["liquor stores"],
    bounds=(45.4, 45.6, -122.8, -122.5),  # (min_lat, max_lat, min_lng, max_lng)
    radius=30
)

# Use the data in your application
for company in results['companies']:
    print(f"{company.name}: {company.email}")

2. CSV Mode - For Spreadsheets

Export data to CSV format for use in Excel, Google Sheets, or other tools.

from pyleadfinder import leadfinder

results = leadfinder(
    places_api_key="YOUR_KEY",
    queries=["coffee shops"],
    bounds=(45.4, 45.6, -122.8, -122.5),
    output_mode="csv"
)

# Outputs: leads.csv

3. KML Mode - For Google My Maps

Output KML files that can be imported directly into Google My Maps.

from pyleadfinder import leadfinder

results = leadfinder(
    places_api_key="YOUR_KEY",
    queries=["restaurants"],
    bounds=(45.4, 45.6, -122.8, -122.5),
    output_mode="kml"
)

# Outputs: leads.kml

How It Works

  1. ZIP Code Optimization: Uses hexagonal grid packing to minimize API calls (40-60% reduction).
  2. Places Search: Multi-threaded search across optimized locations.
  3. Email Extraction: Scrapes company websites for contact info (optional).
  4. Export: Generates output based on selected mode.

Arguments

leadfinder(
    # Required
    places_api_key: str,              # Google Places API key
    queries: list[str],               # Search terms like ["restaurants"]
    bounds: tuple,                    # (min_lat, max_lat, min_lng, max_lng)

    # Optional
    output_name: str = "leads",       # Base filename for outputs
    radius: int = 30,                 # Search radius
    radius_unit: str = "miles",       # Unit: "miles", "km", "meters", "yards"
    output_mode: str = "api",         # "api" (default), "csv", or "kml"
    
    # Advanced Options (kwargs)
    excluded_keywords: list = [],     # Keywords to filter out companies/URLs
    num_workers: int = 10,            # Number of threads for parallel processing
    timeout: int = None,              # Operation timeout in seconds (None = no limit)
    scrape_emails: bool = False       # Scrape websites for emails (Default: False)
)

Output Modes

  • "api" (default): Returns data in a dictionary, no file output.
  • "csv": Generates a CSV file with all company data.
  • "kml": Generates a KML file for Google My Maps import.

About the radius parameter

  • Smaller radius = better coverage and more complete results.
  • Smaller radius = significantly more API calls.
  • The ZIP code optimizer uses this radius to determine coverage density.
  • Example: radius=10 might require 3-4x more ZIP codes than radius=30.

Output Files

API Mode: No files generated - use the returned dictionary with companies, stats, and map_data.

CSV Mode: Spreadsheet export with columns: name, address, city, state, zip_code, phone, website, emails, latitude, longitude, place_id.

KML Mode: Import directly to Google My Maps.

Examples

See examples/ directory for working examples of all three modes.

License

MIT License - Copyright 2025 Austin Rakowski

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyleadfinder-0.1.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyleadfinder-0.1.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file pyleadfinder-0.1.0.tar.gz.

File metadata

  • Download URL: pyleadfinder-0.1.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for pyleadfinder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6fba13746d430da34ff1fb1a8d7ae3f90bde904aa6f5260939e9608cd553fd3e
MD5 85279c65e35a84415d888e6b58604721
BLAKE2b-256 1c7126ffbef27d2e20bf0327c6138a6fd028573a2348cedc1a4c4e165f2dead5

See more details on using hashes here.

File details

Details for the file pyleadfinder-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyleadfinder-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for pyleadfinder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8f280325de0bcf68f3bd3df41cf754b41851abfccdd5f7cfe5e49145dc70288
MD5 faa19c3c6481302eee86a23181b9236b
BLAKE2b-256 ed2d385d5be3c758cac4e1e3abfc82e3540caa85c2f26c490a4d167dcfdc8e89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page