How to Scrape Google Maps Results with a SERP API

Learn how to scrape Google Maps results with a SERP API and Python. Extract business names, ratings, reviews, addresses, phone numbers, websites, place IDs, and GPS coordinates, then export the data to CSV.

talor ai
最後更新於
8 分鐘閱讀

Google Maps results are useful when you need local business data from search.

For example, you may want to collect restaurants in New York, dentists in London, hotels near an airport, repair shops in a city, or competitors appearing in a specific local search result.

A Google Maps SERP result can include fields like:

  • business name

  • rating

  • review count

  • address

  • phone number

  • website

  • business type

  • opening hours

  • place ID

  • GPS coordinates

  • result position

You can try to scrape Google Maps directly with browser automation, but that usually means dealing with page rendering, scrolling, dynamic loading, anti-bot checks, proxy rotation, and frequent layout changes.

A SERP API is usually a simpler option. You send a query and location, then receive structured results in JSON.

In this guide, we will scrape Google Maps results with Python, normalize the data, and export it to CSV.

Why Scrape Google Maps Results?

Google Maps data is useful for many workflows:

  • Local SEO: track which businesses rank for local keywords.

  • Lead generation: collect business names, websites, and contact information.

  • Market research: compare local competitors in different cities.

  • Reputation monitoring: track ratings and review counts.

  • AI agents: give an agent fresh local business data before generating recommendations.

  • Dashboards: build reports for agencies or internal teams.

For example, a local SEO agency may want to search:

dentist in Austin
plumber near Chicago
best coffee shop in Seattle
law firm in Boston

Then it can compare which businesses appear, where they rank, and how their ratings change over time.

Why Use a SERP API?

Scraping Google Maps manually can become fragile very quickly.

You may need to handle:

  • browser rendering

  • infinite scroll

  • dynamic JavaScript

  • blocked requests

  • CAPTCHA challenges

  • changing HTML structure

  • location-specific results

  • mobile vs desktop differences

A SERP API handles most of that collection layer for you.

With a SERP API, your workflow becomes simpler:

Send query + location
→ Receive structured JSON
→ Extract business fields
→ Save to CSV, database, or dashboard

Tools like Talordata, SerpApi, DataForSEO, Bright Data, SearchAPI.io, and Serper.dev can be used for this kind of workflow. The code below is provider-neutral, so you can adapt it to the API you use. View API documentation

What We Will Build

We will create a small Python script that:

  1. sends a Google Maps-style search query to a SERP API

  2. reads the JSON response

  3. extracts local business results

  4. normalizes fields

  5. exports the results to a CSV file

Install the required package first:

pip install requests

Python’s built-in csv module is enough for exporting data, so we do not need extra CSV libraries.

Step 1: Set Your API Key

Use environment variables instead of hardcoding credentials.

export SERP_API_KEY="your_api_key_here"
export SERP_API_ENDPOINT="https://your-serp-api-endpoint.com/search"

On Windows PowerShell:

$env:SERP_API_KEY="your_api_key_here"
$env:SERP_API_ENDPOINT="https://your-serp-api-endpoint.com/search"

Different providers use different endpoint formats. Some use q, some use query. Some use engine=google_maps, while others use type=maps or a dedicated Maps endpoint.

The idea is the same.

Step 2: Request Google Maps Results

Here is a basic request function:

import os
import requests


SERP_API_KEY = os.getenv("SERP_API_KEY")
SERP_API_ENDPOINT = os.getenv("SERP_API_ENDPOINT")


def search_google_maps(query, location="United States"):
    params = {
        "engine": "google_maps",
        "query": query,
        "location": location,
        "output": "json"
    }

    headers = {
        "Authorization": f"Bearer {SERP_API_KEY}"
    }

    response = requests.get(
        SERP_API_ENDPOINT,
        params=params,
        headers=headers,
        timeout=30
    )

    response.raise_for_status()
    return response.json()

Depending on your SERP API provider, you may need to change:

"engine": "google_maps"

to something like:

"type": "maps"

or:

"search_type": "local"

If your provider passes the API key as a query parameter, you can change the request like this:

params["api_key"] = SERP_API_KEY

The important part is to keep the request layer separate from the parsing layer.

Step 3: Normalize Google Maps Results

Different APIs may return Maps results under different keys:

local_results
maps_results
places_results

A flexible parser helps avoid broken code when switching providers.

from datetime import datetime, timezone


def clean_text(value):
    if not value:
        return ""
    return " ".join(str(value).split())


def get_maps_results(serp_json):
    return (
        serp_json.get("local_results")
        or serp_json.get("maps_results")
        or serp_json.get("places_results")
        or []
    )


def normalize_maps_results(serp_json, query, location):
    results = get_maps_results(serp_json)
    collected_at = datetime.now(timezone.utc).isoformat()

    rows = []

    for index, item in enumerate(results, start=1):
        gps = item.get("gps_coordinates") or {}

        rows.append({
            "query": query,
            "location": location,
            "position": item.get("position") or item.get("rank") or index,
            "business_name": clean_text(item.get("title") or item.get("name")),
            "rating": item.get("rating"),
            "reviews": item.get("reviews") or item.get("reviews_count"),
            "business_type": clean_text(item.get("type") or item.get("category")),
            "address": clean_text(item.get("address")),
            "phone": clean_text(item.get("phone")),
            "website": item.get("website") or item.get("link") or "",
            "place_id": item.get("place_id") or item.get("data_id") or item.get("data_cid") or "",
            "latitude": gps.get("latitude"),
            "longitude": gps.get("longitude"),
            "collected_at": collected_at
        })

    return rows

This gives you a clean, stable format that works well for spreadsheets, dashboards, or databases.

Step 4: Export Results to CSV

Now we can write the normalized rows to a CSV file.

import csv


CSV_COLUMNS = [
    "query",
    "location",
    "position",
    "business_name",
    "rating",
    "reviews",
    "business_type",
    "address",
    "phone",
    "website",
    "place_id",
    "latitude",
    "longitude",
    "collected_at"
]


def export_to_csv(rows, filename="google_maps_results.csv"):
    if not rows:
        print("No results to export.")
        return

    with open(filename, mode="w", newline="", encoding="utf-8") as file:
        writer = csv.DictWriter(file, fieldnames=CSV_COLUMNS)
        writer.writeheader()
        writer.writerows(rows)

    print(f"Exported {len(rows)} rows to {filename}")

Complete Example

Here is the full script:

import os
import csv
import requests

from datetime import datetime, timezone


SERP_API_KEY = os.getenv("SERP_API_KEY")
SERP_API_ENDPOINT = os.getenv("SERP_API_ENDPOINT")

CSV_COLUMNS = [
    "query",
    "location",
    "position",
    "business_name",
    "rating",
    "reviews",
    "business_type",
    "address",
    "phone",
    "website",
    "place_id",
    "latitude",
    "longitude",
    "collected_at"
]


def clean_text(value):
    if not value:
        return ""
    return " ".join(str(value).split())


def search_google_maps(query, location="United States"):
    params = {
        "engine": "google_maps",
        "query": query,
        "location": location,
        "output": "json"
    }

    headers = {
        "Authorization": f"Bearer {SERP_API_KEY}"
    }

    response = requests.get(
        SERP_API_ENDPOINT,
        params=params,
        headers=headers,
        timeout=30
    )

    response.raise_for_status()
    return response.json()


def get_maps_results(serp_json):
    return (
        serp_json.get("local_results")
        or serp_json.get("maps_results")
        or serp_json.get("places_results")
        or []
    )


def normalize_maps_results(serp_json, query, location):
    results = get_maps_results(serp_json)
    collected_at = datetime.now(timezone.utc).isoformat()

    rows = []

    for index, item in enumerate(results, start=1):
        gps = item.get("gps_coordinates") or {}

        rows.append({
            "query": query,
            "location": location,
            "position": item.get("position") or item.get("rank") or index,
            "business_name": clean_text(item.get("title") or item.get("name")),
            "rating": item.get("rating"),
            "reviews": item.get("reviews") or item.get("reviews_count"),
            "business_type": clean_text(item.get("type") or item.get("category")),
            "address": clean_text(item.get("address")),
            "phone": clean_text(item.get("phone")),
            "website": item.get("website") or item.get("link") or "",
            "place_id": item.get("place_id") or item.get("data_id") or item.get("data_cid") or "",
            "latitude": gps.get("latitude"),
            "longitude": gps.get("longitude"),
            "collected_at": collected_at
        })

    return rows


def export_to_csv(rows, filename="google_maps_results.csv"):
    if not rows:
        print("No results to export.")
        return

    with open(filename, mode="w", newline="", encoding="utf-8") as file:
        writer = csv.DictWriter(file, fieldnames=CSV_COLUMNS)
        writer.writeheader()
        writer.writerows(rows)

    print(f"Exported {len(rows)} rows to {filename}")


if __name__ == "__main__":
    query = "coffee shops in Seattle"
    location = "Seattle, Washington, United States"

    serp_json = search_google_maps(query, location)
    rows = normalize_maps_results(serp_json, query, location)
    export_to_csv(rows)

After running it, you should get a file named:

google_maps_results.csv

Tips for Better Google Maps Data

Use specific local queries.
coffee shop in Seattle is better than coffee.

Control the location carefully.
City, region, country, and coordinates can change the result set.

Store timestamps.
Local rankings can change over time, so every record should include collected_at.

Keep place identifiers.
Fields like place_id, data_id, or data_cid help match the same business across multiple crawls.

Normalize before storage.
Do not build your dashboard directly on one provider’s raw response format. Test the SERP API for free

FAQ

Can I scrape Google Maps results without a SERP API?

Yes, but it is harder. You may need browser automation, proxy handling, CAPTCHA handling, scrolling logic, and HTML parsing. A SERP API usually gives you structured data faster.

What fields can I collect from Google Maps results?

Common fields include business name, ranking position, rating, review count, address, phone number, website, business category, place ID, and GPS coordinates.

Can I use Google Maps results for local SEO?

Yes. Local SEO teams often use Maps data to monitor rankings, compare competitors, track ratings, and build client reports.

Should I save Google Maps results to CSV or a database?

CSV is fine for small tests and reports. For recurring monitoring across many keywords, cities, and clients, a database is better.

立即開展您的數據業務

加入全球最強大的代理網絡

免費試用