This repository contains working examples of scraping Google Maps search results using:
- Selenium
- Playwright (with stealth)
- HasData Google Maps API
in both Python and Node.js. Each method includes clean and minimal code samples with working selectors and data saving logic.
Python 3.10+ or Node.js 18+
Install required packages:
pip install selenium pandas playwright playwright-stealth
playwright installThe second line downloads the browsers Playwright drives.
Install required packages:
npm install selenium-webdriver playwright playwright-extra playwright-extra-plugin-stealth axiosThe API examples need only axios from that list.
The two folders mirror each other, one script per method.
google-maps-scraper/
│
├── python/
│ ├── selenium_scraper.py
│ ├── playwright_scraper.py
│ ├── hasdata_api_scraper.py
│
├── nodejs/
│ ├── selenium_scraper.js
│ ├── playwright_scraper.js
│ ├── hasdata_api_scraper.js
│
└── README.md
Each script scrapes the same fields, business name, rating, review count, category, services, image, and detail URL. Output is saved in both .json and .csv.
Three routes to the same listings, pick by how defended your volume is.
Classic Google Maps scraping using Selenium with visible browser.
| Parameter | Description | Example |
|---|---|---|
query |
Search query | "pizza in New York" |
max_scrolls |
Number of scroll cycles | 10 |
scroll_pause |
Pause between scrolls | 2 seconds |
max_scrolls |
Scroll repetitions | 10 |
output_file |
Output CSV/JSON filename | "maps_data.csv/json" |
Selenium is the baseline, it breaks first when Maps changes markup.
Runs headless or headful with stealth mode to avoid detection.
| Parameter | Description | Example |
|---|---|---|
query |
Search query | "restaurants in Chicago" |
headless |
Headless mode or not | True |
scroll_pause |
Pause between scrolls | 2 seconds |
max_scrolls |
Scroll repetitions | 10 |
output_file |
Output CSV/JSON filename | "output.csv" |
Stealth keeps the scroll loop alive noticeably longer than the default profile.
Use the Google Maps scraping API by HasData, no browser automation needed.
| Parameter | Description | Example |
|---|---|---|
api_key |
Your HasData API key | "your-key" |
query |
Search query | "bars near San Francisco" |
output_file |
Output file | "results.json / results.csv" |
One request returns parsed listings, so there are no selectors to maintain.
hasdata_reviews_scraper collects the full review feed of one place. Search resolves the place's dataId, then the reviews endpoint returns author, rating, date and text per review, saved to CSV. Verified live, a coffee-shop query returned its place and 8 reviews with full texts.
| Parameter | Description | Example |
|---|---|---|
api_key |
Your HasData API key | "your-key" |
query |
Search query for the place | "coffee shop, Austin, TX" |
output_file |
Output CSV file | "reviews.csv" |
The listing scrapers above capture the review count, this one captures the reviews themselves.
- Selectors change, so verify current class names on Google Maps before a long run.
- Rate limiting responds to random delays, proxies, or the API route.
- For heavy usage, prefer the API or your own headless proxy farm.
These examples are for educational purposes only. Learn more about the legality of web scraping.
-
How to Scrape Google Maps Data Using Python, the tutorial the listing scrapers follow
-
How to Scrape Google Maps Reviews, the tutorial behind the reviews feed script
