The Problem

Engineers needing structured business data from Google Maps face manual collection bottlenecks or brittle scrapers that break when DOM selectors shift. This repo addresses the need for automated extraction of business listings, contacts, reviews, and operational details without building a scraping pipeline from scratch.

What This Does

The repository provides a Python-based Google Maps scraper centered in main.py, which defines 6 functions and 1 class (Place). Execution starts at the main function (main.py:173), which routes to scrape_places (main.py:111) — the primary worker that reaches 4 sub-functions. scrape_places calls extract_place (main.py:40) 11 times on average and setup_logging once. extract_place in turn calls extract_text repeatedly and references the Place class for data modeling. Results flow to save_places_to_csv (main.py:159), which writes to result.csv. The script requires Playwright with a visible (non-headless) Chrome/Chromium instance, and XPaths in main.py may need updating if Google Maps changes its DOM structure. The requirements.txt pins 11 packages but lacks a lockfile, so pip install -r requirements.txt may resolve to different versions across environments.

How It Is Wired

Execution flows: main → scrape_places → extract_place → extract_text (11 calls) + Place class. scrape_places also triggers setup_logging for terminal output. The single call graph contains 7 edges between repository functions — no external library calls are resolved in the internal graph, meaning all orchestration lives within main.py. The Place class (defined at main.py:12) serves as the data model for each scraped business. main itself reaches all 6 functions, giving it the widest blast radius; a change to the extract_place signature ripples through every scrape cycle. The dependency graph shows 0 circular dependencies among internal modules, but the deep nesting (max indentation depth 6) makes control flow hard to follow without guard clauses.

How To Use It

Setup: Clone the repo verbatim:

git clone https://github.com/moses-y/Google-Maps-Scrapper.git
cd Google-Maps-Scrapper
pip install -r requirements.txt
playwright install

Configuration: No environment variables or API keys are documented. The script relies on a visible Chrome/Chromium installation and the Playwright browsers installed via playwright install. The requirements.txt pins specific versions of pyee, pytz, et-xmlfile, numpy, and pandas, but without a lockfile installs may vary.

Running it: Invoke the entry point with search parameters:

python main.py -s "Turkish Restaurants in Toronto Canada" -t 20 -o custom_output.csv
  • -s / --search: Google Maps search query
  • -t / --total: Number of results to scrape
  • -o / --output: Output CSV path (defaults to result.csv)
  • --append: Append to existing CSV instead of overwriting

Real-World Use

A market researcher wants 50 business listings for "coffee shops in Seattle" to analyze review sentiment and operating hours. They run python main.py -s "Coffee shops in Seattle" -t 50 -o seattle_coffee.csv. The script launches a browser, navigates Google Maps, extracts name, address, phone, review count, rating, and hours per listing, then appends all rows to seattle_coffee.csv. The researcher can later load the CSV into a BI tool. If Google Maps updates its DOM, the XPaths in main.py must be adjusted — the script offers no self-healing mechanism.

Code Health & Issues

  • MEDIUM - Enable Dependabot or Renovate: 1 manifest(s), no update bot configured. Without a bot, published advisories sit unpatched until manual audit. Fix: commit .github/dependabot.yml covering the repo ecosystems plus github-actions.
  • MEDIUM - Deep nesting in main.py: Max indentation depth 6 makes control flow hard to follow. Fix: flatten with early returns/guard clauses; extract inner blocks.
  • No test files detected — untested code paths repository-wide.
  • No CI/CD pipeline — no automated build/test gate.
  • Dependencies declared without a lockfile — non-reproducible builds.
  • 5 declared dependencies are behind the current published major version (pyee 3 major behind, pytz 2 major behind, numpy 1 major behind, pandas 1 major behind, et-xmlfile 1 major behind).

The Bottom Line

This repo delivers a functional Google Maps scraper with minimal setup — ideal for one-off data extraction or prototyping, but the pinned dependencies, absence of a lockfile, and unmaintained code path make it unsuitable for production without vetting. The deep nesting in main.py and lack of tests mean any DOM change or dependency upgrade requires careful manual review. Use it for ad-hoc scraping; for ongoing data pipelines, invest in a maintained scraper or allocate time to refactor the nesting and add version pinning.