# Google Maps Lead Extractor with email — One-Page HTML Scraper (`christiangulloa/google-maps-lead-extractor`) Actor

Extract B2B leads including emails from Google Maps via Places API (bring your own API key) or single-page HTML. No credentials in source code.

- **URL**: https://apify.com/christiangulloa/google-maps-lead-extractor.md
- **Developed by:** [Christian G. Ulloa](https://apify.com/christiangulloa) (community)
- **Categories:** Lead generation, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 actor starts

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

### Google Maps Lead with Email Extractor

Extract structured B2B leads **with email addresses** from Google Maps using the official **Places API (New)**, or from a **single static HTML page** (JSON-LD, embedded Maps JSON, custom CSS selectors). Results are pushed to an Apify dataset.

**Unlike most Google Maps Actors published on Apify**, this Actor also scrapes **email addresses** from each business website — most competing Maps scrapers only return phone and website and leave email outreach to you.

**Credentials are never stored in code.** You provide your own [Google Cloud API key](#google-cloud-setup) in the Actor input (secret field).

---

### What does this Actor do?

Two extraction modes:

| Mode | Best for | Credentials needed |
|------|----------|-------------------|
| **Google Places API** (default) | Bulk search — `"plumbers in Austin TX"` | **Google Places API key** |
| **Single page HTML** | JSON-LD business sites, static directories | None (optional proxy) |

The Places API mode returns name, phone, website, address, category, and Google Maps URL. With **email scraping enabled**, it also fetches each business homepage and extracts the best contact email — a step most competing Maps Actors leave to you manually.

**Apify platform advantages:** secret input fields, scheduled runs, API access, proxy rotation, monitoring, CRM integrations.

---

### Google Cloud setup

**You must create your own API key.** This Actor does not ship with Google credentials.

#### Quick steps

1. [Create a Google Cloud project](https://console.cloud.google.com/projectcreate)
2. [Enable billing](https://console.cloud.google.com/billing)
3. Enable **[Places API (New)](https://console.cloud.google.com/apis/library/places.googleapis.com)**
4. Create an **[API key](https://console.cloud.google.com/apis/credentials)** under APIs & Services → Credentials
5. **Restrict the key** to Places API (New) only
6. Paste the key into the Actor input → **Google Places API key** (masked secret)

Full walkthrough with troubleshooting: **[GOOGLE_CLOUD_SETUP.md](./GOOGLE_CLOUD_SETUP.md)**

---

### How to use this Actor

1. Open the Actor in Apify Console.
2. Set **Extraction mode** to **Google Places API**.
3. Paste your **Google Places API key** (never commit this to git).
4. Enter a **Search query** (e.g. `coffee shops in Austin TX`).
5. Set **Max results** and run.
6. Download leads from the **Dataset** tab.

#### Local development

```bash
cd Apify/my-actor
pip install -r requirements.txt
## Edit storage/key_value_stores/default/INPUT.json — add googlePlacesApiKey
python -m my_actor
````

Or: `apify run`

***

### Input

| Field | Required | Description |
|-------|----------|-------------|
| `extractionMode` | Yes | `googlePlacesApi` or `singlePageHtml` |
| `googlePlacesApiKey` | Places mode | **Secret** — your GCP API key |
| `searchQuery` | Places mode | e.g. `"dentists in Chicago"` |
| `scrapeEmailsFromWebsites` | No | Fetch homepage email per listing |
| `startUrl` | HTML mode | Single page URL to parse |
| `maxResults` | No (default 50) | Cap on leads (max 2500) |
| `proxyConfiguration` | No | Apify Proxy (HTML mode) |
| `customSelectors` | No | CSS overrides (HTML mode) |

#### Example input (Places API)

```json
{
  "extractionMode": "googlePlacesApi",
  "googlePlacesApiKey": "YOUR_API_KEY_HERE",
  "searchQuery": "plumbers in Austin TX",
  "maxResults": 50,
  "scrapeEmailsFromWebsites": true
}
```

#### Example input (HTML mode)

```json
{
  "extractionMode": "singlePageHtml",
  "startUrl": "https://example.com/directory",
  "maxResults": 20,
  "customSelectors": {
    "item": "article.listing",
    "name": ".business-name"
  }
}
```

***

### Output

```json
{
  "name": "Joe's Plumbing",
  "category": "Plumber",
  "address": "123 Main St, Austin, TX 78701, USA",
  "phone": "+1 512-555-0100",
  "website": "https://joesplumbing.example",
  "email": "info@joesplumbing.example",
  "rating": null,
  "reviewCount": null,
  "googleMapsUrl": "https://www.google.com/maps/place/?q=place_id:places/ChIJ...",
  "sourceUrl": "plumbers in Austin TX"
}
```

Export as JSON, CSV, or Excel from the Apify Console.

***

### Single-page HTML mode — JavaScript limitation

Google Maps **search** pages (`/maps/search/...`) load listings via **JavaScript**. HTML mode cannot execute JS and usually returns zero leads for search URLs. Use **Places API mode** for Maps bulk search, or HTML mode for place detail URLs / JSON-LD sites.

***

### Pricing / cost estimation

This Actor uses **Pay per event + usage** on the Apify Store. Full setup: **[STORE\_PRICING.md](./STORE_PRICING.md)**.

| Charge | Suggested price | Notes |
|--------|-----------------|--------|
| Actor start | ~$0.00005 / run | Platform event `apify-actor-start` |
| Lead extracted | ~$0.002 / lead | Custom event `lead-extracted` |
| Apify compute | varies | Runtime + memory |
| Google Places API | your GCP bill | BYO API key |

Set **max total charge per run** in Apify Console to cap spend.

***

### FAQ

**Where do I get an API key?** See [GOOGLE\_CLOUD\_SETUP.md](./GOOGLE_CLOUD_SETUP.md).

**Is my API key safe?** Apify marks `googlePlacesApiKey` as a secret in the input UI. Do not paste keys into public GitHub issues or README files.

**Can I use the local CLI instead?** Yes — `localScraper/extract.py` with `export PLACES_API_KEY=...`.

***

### License and responsibility

Comply with [Google Maps Platform Terms](https://cloud.google.com/maps-platform/terms) and applicable privacy/telemarketing laws.

# Actor input Schema

## `extractionMode` (type: `string`):

Use Google Places API for bulk business search by category and location. Use single-page HTML for JSON-LD business sites or static directory pages.

## `googlePlacesApiKey` (type: `string`):

Your Google Maps Platform API key. Stored as a secret in Apify Console — never hard-coded in this Actor.

## `searchQuery` (type: `string`):

Free-text Google Maps search (Places API Text Search). Examples: "plumbers in Austin TX", "dentists 90210".

## `scrapeEmailsFromWebsites` (type: `boolean`):

Fetches each listing's website and extracts a contact email (JSON-LD, mailto, obfuscated patterns). Most Google Maps Actors on Apify do not include email — this is the key differentiator. Adds one HTTP request per business with a website.

## `startUrl` (type: `string`):

The single page URL to fetch and parse (JSON-LD, embedded Maps JSON, or custom CSS selectors).

## `maxResults` (type: `integer`):

Maximum number of lead records to return.

## `proxyConfiguration` (type: `object`):

Optional Apify Proxy (mainly used in single-page HTML mode to reduce blocking).

## `customSelectors` (type: `object`):

Optional CSS selector overrides for single-page HTML mode. Keys: item, name, category, address, phone, website, email, rating, reviewCount, link.

## Actor input object example

```json
{
  "extractionMode": "googlePlacesApi",
  "searchQuery": "coffee shops in Austin TX",
  "scrapeEmailsFromWebsites": true,
  "startUrl": "https://www.google.com/maps/place/Starbucks/@30.2672,-97.7431,17z",
  "maxResults": 50,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "searchQuery": "coffee shops in Austin TX",
    "startUrl": "https://www.google.com/maps/place/Starbucks/@30.2672,-97.7431,17z",
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("christiangulloa/google-maps-lead-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "searchQuery": "coffee shops in Austin TX",
    "startUrl": "https://www.google.com/maps/place/Starbucks/@30.2672,-97.7431,17z",
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("christiangulloa/google-maps-lead-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchQuery": "coffee shops in Austin TX",
  "startUrl": "https://www.google.com/maps/place/Starbucks/@30.2672,-97.7431,17z",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call christiangulloa/google-maps-lead-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=christiangulloa/google-maps-lead-extractor",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Google Maps Lead Extractor with email — One-Page HTML Scraper",
        "description": "Extract B2B leads including emails from Google Maps via Places API (bring your own API key) or single-page HTML. No credentials in source code.",
        "version": "1.4",
        "x-build-id": "CAtUxYTJ0Qk6F1zex"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/christiangulloa~google-maps-lead-extractor/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-christiangulloa-google-maps-lead-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/christiangulloa~google-maps-lead-extractor/runs": {
            "post": {
                "operationId": "runs-sync-christiangulloa-google-maps-lead-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/christiangulloa~google-maps-lead-extractor/run-sync": {
            "post": {
                "operationId": "run-sync-christiangulloa-google-maps-lead-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "extractionMode"
                ],
                "properties": {
                    "extractionMode": {
                        "title": "Extraction mode",
                        "enum": [
                            "googlePlacesApi",
                            "singlePageHtml"
                        ],
                        "type": "string",
                        "description": "Use Google Places API for bulk business search by category and location. Use single-page HTML for JSON-LD business sites or static directory pages.",
                        "default": "googlePlacesApi"
                    },
                    "googlePlacesApiKey": {
                        "title": "Google Places API key",
                        "type": "string",
                        "description": "Your Google Maps Platform API key. Stored as a secret in Apify Console — never hard-coded in this Actor."
                    },
                    "searchQuery": {
                        "title": "Search query",
                        "type": "string",
                        "description": "Free-text Google Maps search (Places API Text Search). Examples: \"plumbers in Austin TX\", \"dentists 90210\"."
                    },
                    "scrapeEmailsFromWebsites": {
                        "title": "Scrape emails from business websites",
                        "type": "boolean",
                        "description": "Fetches each listing's website and extracts a contact email (JSON-LD, mailto, obfuscated patterns). Most Google Maps Actors on Apify do not include email — this is the key differentiator. Adds one HTTP request per business with a website.",
                        "default": true
                    },
                    "startUrl": {
                        "title": "Page URL",
                        "type": "string",
                        "description": "The single page URL to fetch and parse (JSON-LD, embedded Maps JSON, or custom CSS selectors)."
                    },
                    "maxResults": {
                        "title": "Max results",
                        "minimum": 1,
                        "maximum": 2500,
                        "type": "integer",
                        "description": "Maximum number of lead records to return.",
                        "default": 50
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Optional Apify Proxy (mainly used in single-page HTML mode to reduce blocking)."
                    },
                    "customSelectors": {
                        "title": "Custom CSS selectors (advanced)",
                        "type": "object",
                        "description": "Optional CSS selector overrides for single-page HTML mode. Keys: item, name, category, address, phone, website, email, rating, reviewCount, link."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
