Scrape Google Maps Data: 4 Proven Methods You Can Use
Have you ever started copying business names and ratings from Google Maps into a spreadsheet, then wondered how long it would take to finish the list? A Google Maps scraper can handle that repetitive work and collect business details for you. Once the data is in a spreadsheet, you can sort the businesses by rating and compare them in one place.
I’ll show you how to scrape Google Maps for business names and ratings, using pizza in Lincoln Park, Chicago, as the search query throughout the guide. Focusing on one neighborhood keeps the example manageable and makes the output easier to check. We’ll start with Python, then look at no-code tools, browser extensions, and Google’s Places API.
Method 1: Using Python (For Developers)
I’ll start with Python because it lets me control how the search runs and which fields are saved. Since Google Maps loads its business cards with JavaScript, I’ll use Playwright to open the page in Chromium and wait for the cards to appear. The script will then collect the names and ratings of up to 20 businesses and save them to a CSV file.
Before running the example, I would check the planned collection against Google’s Maps terms, which restrict copying and mass downloading. The example below is provided for technical learning and discussion.
Prepare the Proxy Connection
Before setting up the script, I’ll choose how Chromium will connect to Maps. Repeated automated searches can hit IP-based access limits. A residential proxy routes Chromium’s requests through an IP assigned to a home internet connection, allowing me to use a different exit IP for a separate search.
As Chromium scrolls the results panel, Maps requests more data, so response time and availability matter when choosing a proxy. For this walkthrough, I’ll choose IPcook over others because its residential proxy combines an average response time under 0.5 seconds with 99.99% uptime.
1. Set Up Your Environment
I’ll keep the setup small: Python 3.10 or newer, Playwright, and Chromium. If you haven’t installed Python yet, python.org has the version for your operating system. Once Python is installed, the two terminal commands below install Playwright and download Chromium, which Playwright will use to open Google Maps:
python -m pip install --upgrade playwright
python -m playwright install chromiumI’ll save the example in google_maps_pizza_scraper.py, starting with the imports and collection settings below. The script uses Python's csv module for export, so no separate CSV package is required. Placing the query, output filename, and limits near the top makes these settings easier to adjust.
import csv
import re
from urllib.parse import unquote, urlencode
from playwright.sync_api import TimeoutError as PlaywrightTimeoutError
from playwright.sync_api import sync_playwright
QUERY = "pizza in Lincoln Park, Chicago"
OUTPUT_FILE = "lincoln_park_pizza.csv"
MAX_RESULTS = 20
MAX_SCROLLS = 30
WAIT_SECONDS = 42. Configure Proxies
For this single search, I’ll use a residential proxy with a sticky session to keep Chromium’s exit IP consistent while it loads and scrolls through the results. If you’re also using IPcook, open My Proxy > Residential in the dashboard, then select Proxy Generator. Choose Credentials, HTTP, and Sticky IP, and set the country to the United States.
In google_maps_pizza_scraper.py, paste the server address into PROXY_SERVER in http://HOST:PORT format and enter the separate credentials in PROXY_USERNAME and PROXY_PASSWORD. Playwright's proxy settings accept the username and password as separate values, so you can enter them exactly as supplied without URL encoding.
# Paste your generated HTTP endpoint and its separate credentials here.
PROXY_SERVER = "" # Example format: http://HOST:PORT
PROXY_USERNAME = ""
PROXY_PASSWORD = ""
def build_proxy():
if not PROXY_SERVER.strip():
if PROXY_USERNAME or PROXY_PASSWORD:
raise ValueError("Add PROXY_SERVER before supplying proxy credentials.")
return None
proxy = {"server": PROXY_SERVER.strip()}
if PROXY_USERNAME or PROXY_PASSWORD:
proxy.update(username=PROXY_USERNAME, password=PROXY_PASSWORD)
return proxyWhen the script launches Chromium, build_proxy() supplies the proxy settings to Playwright. If you want to run the example without configuring a proxy, leave PROXY_SERVER, PROXY_USERNAME, and PROXY_PASSWORD blank.
3. Write the Scraping Script
With the connection settings in place, open_search() opens the Lincoln Park query through a Google Maps search URL. The browser uses an English interface, so the script can read rating labels such as 4.5 stars. If an English cookie prompt appears, open_search() selects Reject all. Before waiting for the result cards, check_access() checks for verification challenges or access restrictions and stops the run if either is detected.
def check_access(page):
try:
message = page.locator("body").inner_text(timeout=5000).lower()
except PlaywrightTimeoutError as error:
raise RuntimeError(
"Page-content check timed out. Google may be showing an anti-scraping "
"challenge. Inspect the browser before treating this as a network failure."
) from error
restricted = (
"/sorry/" in page.url
or "our systems have detected unusual traffic" in message
or "your computer or network may be sending automated queries" in message
or page.locator('iframe[src*="recaptcha"], #captcha-form').count() > 0
)
if restricted:
raise RuntimeError("Google displayed a verification or access restriction. Run stopped.")
def open_search(page):
parameters = urlencode({"api": "1", "query": QUERY, "hl": "en"})
response = page.goto(
f"https://www.google.com/maps/search/?{parameters}",
wait_until="domcontentloaded",
timeout=60000,
)
if response and response.status >= 400:
raise RuntimeError(f"Search request returned HTTP {response.status}.")
# Decline optional cookies if Google's English consent prompt appears.
reject_button = page.get_by_role("button", name="Reject all", exact=True)
try:
reject_button.wait_for(state="visible", timeout=3000)
reject_button.click()
except PlaywrightTimeoutError:
pass
check_access(page)
try:
page.locator('[role="feed"] div.Nv2PK').first.wait_for(timeout=20000)
except PlaywrightTimeoutError as error:
check_access(page)
raise RuntimeError(
"No result cards appeared. Inspect the browser for consent, an empty "
"search, or a changed Maps layout before adjusting the selectors."
) from errorThe business cards appear in the scrollable results panel beside the map. The script locates that panel using role="feed" and finds the individual cards using Nv2PK. If the expected cards do not appear, the script reports the problem and stops before extraction. Chromium stays visible so you can inspect the page.
Once the cards are available, read_cards() reads each business name and rating, while collect_listings() repeats the extraction as the results panel scrolls. The collected entries stay in memory even if Maps removes older cards from the page. Identifiers from the business links let the script recognize previously collected businesses and avoid duplicate rows.
def read_cards(feed):
# Read each card as one snapshot so its name and rating stay together.
cards = feed.locator("div.Nv2PK").evaluate_all("""cards => cards.map(card => {
const link = card.querySelector('a[href*="/maps/place/"][aria-label]');
return {
name: link?.getAttribute('aria-label')?.trim() || '',
url: link?.href || '',
labels: Array.from(card.querySelectorAll('[role="img"][aria-label]'))
.map(node => node.getAttribute('aria-label'))
};
})""")
rows = []
for card in cards:
if not card["name"] or not card["url"]:
continue
rating = ""
for label in card["labels"]:
match = re.search(r"\b([0-5](?:[.,]\d+)?)\s+stars?\b", label, re.I)
if match:
rating = match.group(1).replace(",", ".")
break
# Prefer the place identifier over URL details that can change between views.
identifier = re.search(r"!1s([^!/?]+)", unquote(card["url"]))
key = identifier.group(1) if identifier else card["url"].split("?")[0]
rows.append((key, {"Business Name": card["name"], "Rating": rating}))
return rows
def collect_listings(page, max_results=MAX_RESULTS, max_scrolls=MAX_SCROLLS,
wait_seconds=WAIT_SECONDS):
feed = page.locator('[role="feed"]').first
results = {}
unchanged = 0
for scroll in range(max_scrolls + 1):
check_access(page)
for key, row in read_cards(feed):
if key not in results:
results[key] = row
elif not results[key]["Rating"] and row["Rating"]:
results[key]["Rating"] = row["Rating"]
if len(results) >= max_results:
return list(results.values())
print(f"Collected {len(results)} unique businesses.")
if unchanged >= 2 or scroll == max_scrolls:
break
previous_links = feed.locator('a[href*="/maps/place/"]').evaluate_all(
"links => links.map(link => link.href).join('\\n')"
)
# Space out scroll requests even when the next batch loads immediately.
page.wait_for_timeout(1000)
# Scroll the results panel rather than the map or the whole webpage.
feed.evaluate("element => element.scrollTop = element.scrollHeight")
try:
page.wait_for_function("""previous => {
const feed = document.querySelector('[role="feed"]');
if (!feed) return false;
const links = Array.from(feed.querySelectorAll('a[href*="/maps/place/"]'));
return links.map(link => link.href).join('\\n') !== previous;
}""", arg=previous_links, timeout=wait_seconds * 1000)
unchanged = 0
except PlaywrightTimeoutError:
unchanged += 1
if not results:
raise RuntimeError("Result cards appeared, but the name/link selectors found no businesses.")
return list(results.values())Before each scroll, the script pauses for one second, then scrolls the results panel and waits for the business links to change. It stops when it reaches MAX_RESULTS (20 businesses), MAX_SCROLLS (30 scrolls), or two consecutive waits with no change. WAIT_SECONDS sets the maximum time the script waits for the business links to change after each scroll. A slower connection may require a higher value.
4. Run the Script and Export the Results
The main function, scrape_google_maps(), starts Chromium and runs the search and collection functions in order. It then passes the collected rows to save_results() for CSV export. The finally block closes the browser whether the run succeeds or stops on an error.
def save_results(results, filename=OUTPUT_FILE):
# UTF-8 with a BOM preserves business names when Excel opens the CSV.
with open(filename, "w", newline="", encoding="utf-8-sig") as file:
writer = csv.DictWriter(file, fieldnames=["Business Name", "Rating"])
writer.writeheader()
writer.writerows(results)
print(f"Saved {len(results)} businesses to {filename}.")
def scrape_google_maps():
with sync_playwright() as playwright:
options = {"headless": False}
proxy = build_proxy()
if proxy:
options["proxy"] = proxy
browser = playwright.chromium.launch(**options)
try:
context = browser.new_context(locale="en-US", viewport={"width": 1440, "height": 1000})
page = context.new_page()
open_search(page)
results = collect_listings(page)
save_results(results)
finally:
browser.close()
if __name__ == "__main__":
try:
scrape_google_maps()
except (RuntimeError, ValueError, PlaywrightTimeoutError) as error:
raise SystemExit(f"Collection stopped: {error}") from errorThe Complete Code
The complete script below combines the configuration and functions shown above.
import csv
import re
from urllib.parse import unquote, urlencode
from playwright.sync_api import TimeoutError as PlaywrightTimeoutError
from playwright.sync_api import sync_playwright
QUERY = "pizza in Lincoln Park, Chicago"
OUTPUT_FILE = "lincoln_park_pizza.csv"
MAX_RESULTS = 20
MAX_SCROLLS = 30
WAIT_SECONDS = 4
# Paste your generated HTTP endpoint and its separate credentials here.
PROXY_SERVER = "" # Example format: http://HOST:PORT
PROXY_USERNAME = ""
PROXY_PASSWORD = ""
def build_proxy():
if not PROXY_SERVER.strip():
if PROXY_USERNAME or PROXY_PASSWORD:
raise ValueError("Add PROXY_SERVER before supplying proxy credentials.")
return None
proxy = {"server": PROXY_SERVER.strip()}
if PROXY_USERNAME or PROXY_PASSWORD:
proxy.update(username=PROXY_USERNAME, password=PROXY_PASSWORD)
return proxy
def check_access(page):
try:
message = page.locator("body").inner_text(timeout=5000).lower()
except PlaywrightTimeoutError as error:
raise RuntimeError(
"Page-content check timed out. Google may be showing an anti-scraping "
"challenge. Inspect the browser before treating this as a network failure."
) from error
restricted = (
"/sorry/" in page.url
or "our systems have detected unusual traffic" in message
or "your computer or network may be sending automated queries" in message
or page.locator('iframe[src*="recaptcha"], #captcha-form').count() > 0
)
if restricted:
raise RuntimeError("Google displayed a verification or access restriction. Run stopped.")
def open_search(page):
parameters = urlencode({"api": "1", "query": QUERY, "hl": "en"})
response = page.goto(
f"https://www.google.com/maps/search/?{parameters}",
wait_until="domcontentloaded",
timeout=60000,
)
if response and response.status >= 400:
raise RuntimeError(f"Search request returned HTTP {response.status}.")
# Decline optional cookies if Google's English consent prompt appears.
reject_button = page.get_by_role("button", name="Reject all", exact=True)
try:
reject_button.wait_for(state="visible", timeout=3000)
reject_button.click()
except PlaywrightTimeoutError:
pass
check_access(page)
try:
page.locator('[role="feed"] div.Nv2PK').first.wait_for(timeout=20000)
except PlaywrightTimeoutError as error:
check_access(page)
raise RuntimeError(
"No result cards appeared. Inspect the browser for consent, an empty "
"search, or a changed Maps layout before adjusting the selectors."
) from error
def read_cards(feed):
# Read each card as one snapshot so its name and rating stay together.
cards = feed.locator("div.Nv2PK").evaluate_all("""cards => cards.map(card => {
const link = card.querySelector('a[href*="/maps/place/"][aria-label]');
return {
name: link?.getAttribute('aria-label')?.trim() || '',
url: link?.href || '',
labels: Array.from(card.querySelectorAll('[role="img"][aria-label]'))
.map(node => node.getAttribute('aria-label'))
};
})""")
rows = []
for card in cards:
if not card["name"] or not card["url"]:
continue
rating = ""
for label in card["labels"]:
match = re.search(r"\b([0-5](?:[.,]\d+)?)\s+stars?\b", label, re.I)
if match:
rating = match.group(1).replace(",", ".")
break
# Prefer the place identifier over URL details that can change between views.
identifier = re.search(r"!1s([^!/?]+)", unquote(card["url"]))
key = identifier.group(1) if identifier else card["url"].split("?")[0]
rows.append((key, {"Business Name": card["name"], "Rating": rating}))
return rows
def collect_listings(page, max_results=MAX_RESULTS, max_scrolls=MAX_SCROLLS,
wait_seconds=WAIT_SECONDS):
feed = page.locator('[role="feed"]').first
results = {}
unchanged = 0
for scroll in range(max_scrolls + 1):
check_access(page)
for key, row in read_cards(feed):
if key not in results:
results[key] = row
elif not results[key]["Rating"] and row["Rating"]:
results[key]["Rating"] = row["Rating"]
if len(results) >= max_results:
return list(results.values())
print(f"Collected {len(results)} unique businesses.")
if unchanged >= 2 or scroll == max_scrolls:
break
previous_links = feed.locator('a[href*="/maps/place/"]').evaluate_all(
"links => links.map(link => link.href).join('\\n')"
)
# Space out scroll requests even when the next batch loads immediately.
page.wait_for_timeout(1000)
# Scroll the results panel rather than the map or the whole webpage.
feed.evaluate("element => element.scrollTop = element.scrollHeight")
try:
page.wait_for_function("""previous => {
const feed = document.querySelector('[role="feed"]');
if (!feed) return false;
const links = Array.from(feed.querySelectorAll('a[href*="/maps/place/"]'));
return links.map(link => link.href).join('\\n') !== previous;
}""", arg=previous_links, timeout=wait_seconds * 1000)
unchanged = 0
except PlaywrightTimeoutError:
unchanged += 1
if not results:
raise RuntimeError("Result cards appeared, but the name/link selectors found no businesses.")
return list(results.values())
def save_results(results, filename=OUTPUT_FILE):
# UTF-8 with a BOM preserves business names when Excel opens the CSV.
with open(filename, "w", newline="", encoding="utf-8-sig") as file:
writer = csv.DictWriter(file, fieldnames=["Business Name", "Rating"])
writer.writeheader()
writer.writerows(results)
print(f"Saved {len(results)} businesses to {filename}.")
def scrape_google_maps():
with sync_playwright() as playwright:
options = {"headless": False}
proxy = build_proxy()
if proxy:
options["proxy"] = proxy
browser = playwright.chromium.launch(**options)
try:
context = browser.new_context(locale="en-US", viewport={"width": 1440, "height": 1000})
page = context.new_page()
open_search(page)
results = collect_listings(page)
save_results(results)
finally:
browser.close()
if __name__ == "__main__":
try:
scrape_google_maps()
except (RuntimeError, ValueError, PlaywrightTimeoutError) as error:
raise SystemExit(f"Collection stopped: {error}") from errorAfter saving the complete file, run this command from the folder containing google_maps_pizza_scraper.py:
python google_maps_pizza_scraper.pyAfter a successful run, the script creates lincoln_park_pizza.csv in the folder where you ran the command. The file contains up to 20 business entries under the Business Name and Rating columns. A blank rating means the parser did not find a matching star label for that card.
Get IPcook’s stories in your inbox
Join Medium for free to get updates from this writer.
Before comparing ratings, I would check a few CSV rows against their Maps cards, including any entries with blank ratings. That check helps distinguish unrated businesses from labels the parser missed and can reveal selectors that need updating after a layout change. The file reflects the results collected for this query, rather than a complete directory of pizza shops in Lincoln Park.
Method 2: Using No-Code Tools (For Non-Tech Users)
If you prefer not to write code, tools such as Octoparse, ParseHub, and Apify offer visual interfaces or prepared tasks for collecting web data. The best Google Maps scraper for your task will depend on the fields you need and how much of the workflow you want to configure yourself.
Here, I’ll use Octoparse’s Google Maps Listings Scraper by Keywords template to show how to scrape data from Google Maps. It accepts a search phrase and includes business names and ratings in the output.
- Create the task. Install Octoparse and open the Google Maps Listings Scraper by Keywords template. Enter
pizza in Lincoln Park, Chicagoas the search keyword and select English as the language. - Run the collection. Start the task and inspect the first returned listings. Confirm that the output includes the
NameandRatingfields for the Lincoln Park search. - Export the results. Once the collection finishes, export the data as CSV or Excel. Keep the name and rating columns for this example, then compare a few entries with their Maps listings.
A template reduces setup work but limits customization to the settings it provides. I’d build a custom visual workflow if the template couldn’t produce the fields or collection sequence I needed.
Method 3: Using Browser Extensions
Browser extensions offer another way to scrape Google Maps from the page you’re viewing. For a small list, I’d use this approach when I want to export results directly from Chrome. The steps below use Scraper Pro as an example.
- Install and sign in. Install Scraper Pro from the Chrome Web Store, open Google Maps, and sign in with Google through the extension panel.
- Collect the example results. Search Maps for
pizza in Lincoln Park, Chicago, and keep the map centered on Lincoln Park. Click Extract in the Scraper Pro panel, then click Stop after collecting about 20 entries. - Choose columns and export. Open CSV columns > Choose from the extension’s toolbar pop-up. Since Scraper Pro can expand its search into nearby areas, keep the business name, average rating, and full address columns to verify the location. Click CSV in the panel to download the file.
Check the exported addresses and remove businesses outside Lincoln Park, then keep the name and rating columns for the final spreadsheet.
Method 4: Using the Official Google Places API
Google’s Places API provides an alternative to a Google Maps data scraper that reads the Maps webpage. Text Search (New) returns structured place records, so this method doesn’t need browser scrolling or HTML selectors. I’ll use the same Lincoln Park query to request business names and ratings.
- Set up API access. In Google Cloud Console, create or select a project, enable billing and the Places API (New), and create a restricted API key.
- Submit the search. From a terminal, adapt Google’s cURL request example to send a POST request to the API endpoint,
https://places.googleapis.com/v1/places:searchText. In the JSON body, settextQuerytopizza in Lincoln Park, Chicago, andpageSizeto20. Use your key in theX-Goog-Api-Keyheader and setX-Goog-FieldMasktoplaces.displayName,places.rating. - Read the response. In the returned
placesarray, read each business name fromdisplayName.textand its rating fromrating. The response is JSON, so spreadsheet use requires a separate conversion step.
Before choosing the API for a spreadsheet project, I would check the charges for the requested fields and whether Google’s Places API policies permit the planned storage and use of the returned records.
Best Practices for Google Maps Scraping
When running a project to scrape Google Maps, a few best practices can make a big difference:
- Control your request rate: Add delays between actions to mimic real users
- Clean your data: Remove duplicates and fix formatting issues
- Stay compliant: Only collect publicly available data and check relevant regulations
These steps help improve both data quality and long-term stability.
Conclusion
Learning how to scrape Google Maps can help you access useful business data more easily. The best method depends on your goals, your technical level, and how much data you need to collect. No matter which approach you choose, the key is to keep the process stable, efficient, and consistent. If you have tried different methods yourself, feel free to leave a comment and share what worked best for you.







