Skip to content
← blog  /  scrapers

Google Maps scraper in Python: 120 places a search, phones in the data, no review counts

2026-12-02  ·  14 min read  ·  scrapers

A Google Maps search lists 120 places and stops. Signed out, most cards show no phone and almost none a review count, but the JSON the page loads has a phone for 65 to 100 % of the places. How to read it with Playwright within robots.txt, and what to clean before it goes into a CSV.

Google Maps has no export button, but a browser that runs a search receives the places as JSON, and robots.txt lets it: the search pages under /maps/search/ are open, and so is /search?tbm=map, the address the list loads its places from, although robots.txt closes the rest of /search.

On 3 November 2026 we ran five searches, signed out, in plain headless Chromium from a UK address: dentist, plumber and coffee shop in Berlin, dentist in Austin, TX, and dentist in Berlin once more with the page in German. We scrolled each list to its end, five seconds between scrolls, and opened 11 place pages.

The short version#

  • 120 places, then the list ends. All five lists stopped at 120 and said so: "You've reached the end of the list". The page fetched the places as JSON, 20 at a time.
  • Some places come twice. The 120 rows held 110 to 118 different places. Keep one row per place id.
  • Signed out, Maps is a "limited view". Only plumber cards showed phone numbers, and 2 of 600 cards a review count. The JSON behind the cards had a phone for 65 % of the coffee shops, 95 % of the plumbers and 98 to 100 % of the dentists, and a website for 81 to 100 %.
  • No review counts, and hours for today only. Of 457 places, 2 came with a review count and a week of opening hours; the rest had today's hours or none. The place pages did not add them.
  • The language changes names, not just labels. With the page in German, 30 of the 100 dentists that both lists shared had a different name.

What robots.txt opens and closes#

Google's robots.txt closes /search and /maps/, then opens parts of them again. For a Maps search:

  • Open: /maps/search/ (the search page), /maps/place/ (place pages), /maps/preview (a place page's data) and /search?*tbm=map (the list's data).
  • Closed: /maps/vt/, the map tiles. Our pages asked for them 4,608 times; our route handler refused every one, and the list did not need them.
  • Closed as well: /searchviewer/, where the Order online buttons on coffee shop cards lead (28 of 120). Disallow: /search covers it.

Read the file with an RFC 9309 reader: the longest matching rule wins, and * is a wildcard. Python 3.10's urllib.robotparser takes the first rule that matches and knows no wildcards, so it calls the search page, the place pages and /search?tbm=map blocked. That errs on the safe side, but it stops you before you start.

The code#

search() opens the search, says no to the cookie screen if one comes, and scrolls the list until it ends, or until it shows most places. A listener keeps the JSON answers the page receives, and row() reads each place from them. Every request the page starts goes through Robots, which checks it against the robots.txt of its host; images, fonts and media are not loaded at all. Playwright does not pass redirects to a route handler; in our run they went to the consent screen and back to the Maps page asked for. If Google shows a CAPTCHA, a sign-in page or its unusual traffic page, check() raises Wall: stop there. In our run none came.

Google Maps search results as rows, within robots.txtpython
import csv, json, re, urllib.error, urllib.parse, urllib.request
from playwright.sync_api import sync_playwright


def robots_rules(text, agent="*"):
    """The Allow and Disallow lines of robots.txt for this agent: its own group, or else the * group."""
    groups, group, after_agent = [], None, False
    for line in text.splitlines():
        line = line.split("#", 1)[0].strip()
        if ":" not in line:
            continue
        field, value = (s.strip() for s in line.split(":", 1))
        field = field.lower()
        if field == "user-agent":
            if group is None or not after_agent:
                group = {"agents": [], "rules": []}
                groups.append(group)
            group["agents"].append(value.lower())
            after_agent = True
        elif field in ("allow", "disallow"):
            if group is not None and value:
                group["rules"].append((field == "allow", value))
            after_agent = False
        elif field != "sitemap":
            after_agent = False
    picked = [g for g in groups if agent in g["agents"]] or [g for g in groups if "*" in g["agents"]]
    return [rule for g in picked for rule in g["rules"]]


def allowed(rules, path):
    """RFC 9309: the longest matching rule wins and Allow wins a tie; * matches anything, $ ends the path."""
    best = None
    for allow, pattern in rules:
        body, end = (pattern[:-1], "$") if pattern.endswith("$") else (pattern, "")
        if re.match(re.escape(body).replace(r"\*", ".*") + end, path):
            if best is None or (len(pattern), allow) > (len(best[1]), best[0]):
                best = (allow, pattern)
    return best is None or best[0]


def robots_txt(origin):
    try:
        req = urllib.request.Request(origin + "/robots.txt", headers={"User-Agent": "Mozilla/5.0"})
        return urllib.request.urlopen(req, timeout=20).read().decode("utf-8", "replace")
    except urllib.error.HTTPError as e:
        return "" if e.code < 500 else "User-agent: *\nDisallow: /"     # 4xx: no rules; 5xx: stay out
    except OSError:
        return "User-agent: *\nDisallow: /"


class Robots:
    """A route handler: a request leaves the browser only if its host's robots.txt allows the path.
    Images, fonts and media are never loaded; the data is in the JSON answers."""

    def __init__(self):
        self.rules, self.refused = {}, []

    def __call__(self, route):
        req = route.request
        url = urllib.parse.urlsplit(req.url)
        if url.scheme not in ("http", "https"):
            return route.continue_()
        if req.resource_type in ("image", "media", "font"):
            return route.abort()
        origin = f"{url.scheme}://{url.netloc}"
        if origin not in self.rules:
            self.rules[origin] = robots_rules(robots_txt(origin))
        if allowed(self.rules[origin], url.path + ("?" + url.query if url.query else "")):
            return route.continue_()
        self.refused.append(req.url)
        return route.abort()


class Wall(Exception):
    """A CAPTCHA, a sign-in page or the unusual-traffic page: stop and do not retry."""


def check(page):
    if "/sorry/" in page.url or "accounts.google.com" in page.url or any("recaptcha" in f.url for f in page.frames):
        raise Wall(page.url)
    text = page.locator("body").inner_text(timeout=5000).lower()
    if any(w in text for w in ("unusual traffic", "not a robot", "captcha")):
        raise Wall(page.url)


def open_maps(p):
    browser = p.chromium.launch()
    context = browser.new_context(viewport={"width": 1280, "height": 900}, locale="en-US", service_workers="block")
    context.route("**/*", Robots())
    return browser, context.new_page()


def reject_cookies(page, url):
    """Google's consent screen (EU and UK): Reject all, wait for the SOCS cookie, then load the page again."""
    page.locator('button[aria-label="Reject all"]').first.click(no_wait_after=True)
    for _ in range(30):
        page.wait_for_timeout(1000)          # not time.sleep: it would stall every routed request
        if any(c["name"] == "SOCS" for c in page.context.cookies()):
            break
    page.goto(url, wait_until="load", timeout=60_000)


def search(page, query, hl="en", pause=5, most=None):
    """The places a Maps search lists (all, or the first `most`), read from the JSON answers the page loads
    while its list scrolls."""
    answers = []
    keep = lambda r: answers.append(r) if "/search?tbm=map" in r.url else None
    page.on("response", keep)
    url = f"https://www.google.com/maps/search/{urllib.parse.quote_plus(query)}?hl={hl}"
    page.goto(url, wait_until="load", timeout=60_000)
    if "consent.google.com" in page.url:
        reject_cookies(page, url)
    page.wait_for_timeout(pause * 1000)
    check(page)
    page.wait_for_selector('div[role="feed"]', timeout=20_000)
    counts = []
    for _ in range(60):
        counts.append(page.locator('div[role="feed"] a[href*="/maps/place/"]').count())
        if (page.get_by_text("reached the end of the list").count() or counts[-4:] == counts[-1:] * 4
                or (most and counts[-1] >= most)):
            break
        page.locator('div[role="feed"]').evaluate("feed => feed.scrollBy(0, 4000)")
        page.wait_for_timeout(pause * 1000)
        check(page)
    page.remove_listener("response", keep)
    rows = {}
    for answer in answers:
        for place in places_in(answer.text()):
            rows.setdefault(place[10], row(place))   # the list repeats places: keep each one once
    return list(rows.values())[:most]


def dig(x, *path):
    """x[a][b]..., or None where the answer has no such element."""
    for k in path:
        if not isinstance(x, list) or k >= len(x):
            return None
        x = x[k]
    return x


def places_in(body):
    """The place arrays of one list answer. It starts with )]}' so that it cannot run as a script."""
    data = json.loads(body.split("\n", 1)[1])
    return [entry[1] for entry in dig(data, 64) or [] if dig(entry, 1)]


def row(p):
    today = dig(p, 203, 0, 0)                     # [day, n, [y, m, d], [[hours, ...], ...], ...]
    return {
        "place_id": dig(p, 78), "name": dig(p, 11), "category": dig(p, 13, 0),
        "categories": dig(p, 13) or [], "address": dig(p, 39), "lat": dig(p, 9, 2), "lng": dig(p, 9, 3),
        "phone": dig(p, 178, 0, 0), "phone_e164": dig(p, 178, 0, 3), "website": dig(p, 7, 0),
        "rating": dig(p, 4, 7), "reviews": dig(p, 4, 8), "price": dig(p, 4, 2),
        "day": dig(today, 0), "hours": ", ".join(h[0] for h in dig(today, 3) or []) or None,
        "status": dig(p, 203, 1, 4, 0), "time_zone": dig(p, 30), "feature_id": dig(p, 10),
    }


def write_csv(rows, path):
    with open(path, "w", newline="", encoding="utf-8") as f:
        out = csv.DictWriter(f, fieldnames=list(rows[0]))
        out.writeheader()
        for r in rows:
            out.writerow({**r, "categories": "; ".join(r["categories"])})
Run itpython
with sync_playwright() as p:
    browser, page = open_maps(p)
    rows = search(page, "coffee shop in Berlin", most=40)
    browser.close()
write_csv(rows, "coffee-shops-berlin.csv")
print(len(rows), "places,", sum(1 for r in rows if r["phone"]), "with a phone,",
      sum(1 for r in rows if r["website"]), "with a website")
print(rows[0])

At 10:53 on 3 November, in a fresh browser, it printed 33 places, 17 with a phone and 25 with a website: the first 40 rows of the list held 33 different places, as in our full coffee shop search 38 minutes earlier, though one place differed. The first: Refinery High End Coffee, Coffee shop, Albrechtstraße 11B, phone +49 30 30874491, a website, rating 4.6, no review count, open today "8 am–6 pm". Without most, our full search gave 110 places from 120 rows.

The positions in the place arrays (11 for the name, 178 for the phone, 7 for the website) come from reading the answers, not from any documentation. On our 480 rows with saved answers, the name matched the card every time, and the rating matched the stars on every card that showed stars. If Google moves them, these checks are the quick way to find out.

What the cards show, and what they do not#

Signed out, every list ended with a notice: "You're seeing a limited view of Google Maps." The cards show the name, the stars, the category, the street and whether the place is open now. What they do not show:

  • Review counts: on 2 of 600 cards only.
  • Phone numbers and websites, except for plumbers: 114 of the 120 plumber cards showed a phone and 97 a Website button, while none of the 480 dentist and coffee shop cards showed either.
  • The website, for dentists. Their cards have Book online instead (93 of 120 in Berlin, 46 of 120 in Austin), which links to a booking service such as doctolib.de, dr-flex.de or flexbook.me, or to a Google Maps page. A scraper that takes the card's link as the website stores the booking service.

The card text also carries icons as private-use characters: the sign between a dentist's category and street comes through as U+E934.

What the data behind the list holds#

  • Plumber in Berlin, 118 places: phone 112 (95 %); website 95 (81 %); address 102 (86 %). The two of the 16 without an address that we opened had none on their place page either, so an empty address is not a reading error.
  • Coffee shop in Berlin, 110: phone 72 (65 %); website 94 (85 %), and for 7 of them it is an Instagram or Facebook page; address for all.
  • Dentist in Austin, TX, 113: phone, website and address for all 113. 34 of the websites carry utm_ tracking parameters.
  • Dentist in Berlin, in German, 116: phone 114 (98 %), website 113 (97 %), 25 of them with utm_ parameters; address for all.

Ratings were there for 97 to 100 %, and every place had at least one category, up to 10; Austin dentists had 6.0 on average. A price level came with 1 of the 110 coffee shops. No card in 600 was marked Sponsored. Drop utm_ parameters before you compare websites.

Opening hours: today only, with two characters you cannot see#

  • Today only. The data gave hours for one day only, Tuesday, the day of the run, for 441 of the 457 places, and no hours at all for 14. The other 2, Romeo und Romeo and Austin 3D Dental, had more days than that and were also the two with a review count. The 11 place pages showed no week either.
  • Not a hyphen. "8 am–6 pm" has an en dash between the times and a narrow no-break space (U+202F) before am and pm. All 278 English time ranges were written that way, and not one used a hyphen. Split on the en dash and turn U+202F into a space.
  • Two ranges a day for 2 plumbers, 2 Austin dentists and 8 Berlin dentists, such as "8 am–12 pm, 1–4:30 pm" (the 1 has no pm of its own) or "09:00–13:00, 14:00–18:00". row() joins them with a comma, so the afternoon is not lost.
  • Words instead of times: Open 24 hours for 38 plumbers; Closed for 7 coffee shops and 2 Austin dentists.
  • In German: "08:00–20:00" with the same en dash, and Geschlossen.

Phone numbers come in three forms#

Each of the 411 numbers is in the data in three forms: as shown, "+49 30 30874491"; national, "030 30874491" or "(512) 717-3147"; and plain, "+493030874491". row() keeps the first and the last. Compare and deduplicate on phone_e164.

Key on the place id, never the name#

The list repeats places: 120 rows held 114 places for dentist in Berlin, 118 for plumbers, 110 for coffee shops, 113 in Austin and 116 in German. search() keeps the first row of each place. Names cannot serve as the key, because they change with the language.

What the language changes#

The same search, dentist in Berlin, with hl=en and hl=de, eight minutes apart:

  • Names: 30 of the 100 places in both lists had another name. "torhaus - Your Dentists in Berlin" was "Torhaus - Ihre Zahnärzte in Berlin Mitte", and "Kottident - Dentist in Berlin Kreuzberg" was "Kottident - Zahnarzt Kreuzberg".
  • Labels: Dentist became Zahnarzt, the hours "08:00–20:00", and the addresses end in Deutschland.
  • Stars on the cards: "4,9 Sterne", with a decimal comma and a no-break space. The rating in the data is the number 4.9 in both languages, and it agreed on all 100.
  • Which places: 114 in English, 116 in German, 100 in both, and only 10 at the same position. The two runs were eight minutes apart, so part of that may be ordinary change.
  • Where you connect from counts too: Maps took gl=uk from our UK address, and the Austin dentists came with British categories such as Paediatric Dentist and Denture Care Centre.

Place pages added nothing#

We opened 11 place pages: 3 coffee shops without a phone in the list, 2 plumbers without an address, 2 without a website, 2 Austin dentists and one Berlin dentist in both languages. None showed a review count or a week of hours, and none filled a gap. On the 10 we could compare with the list's data, phone, website, address and rating were the same; one coffee shop had Cafe as its first category on its page and Coffee shop in the list.

Two things about the browser#

  • The cookie screen. From the UK, the first page was Google's consent screen. reject_cookies() clicks Reject all, waits for the SOCS cookie and loads the page again, because the redirect that should follow did not arrive: the browser's request for the next page was still open 125 seconds later.
  • page.wait_for_timeout(), not time.sleep(). Playwright's sync API runs a Python route handler only while your code is inside a Playwright call. With time.sleep() in the waiting loop, the same click on Reject all reached Google 69.8 seconds after the page began to load; with page.wait_for_timeout(), after 4.7.

Every day, at scale#

For many searches on a schedule, our Google Maps Scraper on Apify does the reading. Search by keyword and city, or paste Maps search links. Each place comes back as one row with name, category, address, coordinates, rating, phone, website, place ID and Maps link. It reads public pages only, with no login, keeps to robots.txt, and stops and says so when Google shows a consent page, a CAPTCHA or an unusual-traffic page. Unlike the script above, it does not click Reject all. Its rows also differ from row() where we gave cleaning advice: phone is the number as shown, with no phone_e164; website keeps its utm_ parameters; openingHours is a list of days and hours with a hyphen and plain spaces, and several ranges in a day joined by a comma; and reviewsCount and openingHours are null when the page gives none. It is billed per result. How to set it up, step by step: Google Maps export.

written