DEV Community

Cover image for How I Built a Google Maps Scraper to Generate Leads for My New Agency (And Why I Open-Sourced It)
Jerry Satpathy
Jerry Satpathy

Posted on

How I Built a Google Maps Scraper to Generate Leads for My New Agency (And Why I Open-Sourced It)

When you're building a brand-new agency, there’s one problem you can’t escape:

Finding clients.

Before we had a portfolio, before we had referrals, before anyone even knew our name — we needed a reliable way to identify businesses that might need websites, branding, software, or digital marketing.

At Code Media Labs — my newly formed agency — that responsibility fell on me.

And like many new founders, I turned to the simplest place to find businesses:

Google Maps.

Google Maps The OG Lead Generator Machine


The Struggle Every New Agency Knows

If you've ever done manual prospecting, you know the routine:

  • Search “Interior Designers near me”

  • Scroll, scroll, scroll

  • Click each listing

  • Copy the name, phone, rating, URL

  • Paste into a spreadsheet

  • Repeat 150+ times

It’s slow. It's painful. And it steals hours from the work that actually builds your agency.

One night — after manually extracting yet another list — I said:

“Enough. I’m automating this.”

And that turned into a tool that helped my agency survive its early months.


From Internal Hack → Lead Machine

I opened VS Code and wrote a small Puppeteer script:

  • Launch Google Maps

  • Search for a keyword

  • Scroll automatically

  • Extract business details

  • Save everything cleanly

The first version was rough. But it worked.

I could instantly generate lists like:

  • Cafes in Cuttack

  • Marketing agencies in Bhubaneswar

  • Retail shops in Saheed Nagar

  • Manufacturers across Odisha

For a brand-new agency, this sped up our outreach dramatically.

Instead of spending hours gathering data, I could spend hours pitching and closing.

Every Developer Automates Every Single Task

Why I Decided to Open-Source It

Initially, the scraper was private — a purely internal survival tool.

But the more I talked to other freelancers and small agencies, the more I realised:

“Everyone is struggling with lead generation, especially early on.”

So I cleaned up the tool, added a CLI, refined the output, wrote proper documentation, and published it.

Originally, I wanted to publish it as a scoped package (@cml/google-maps-scraper), but scoped namespaces are paid.

So I renamed it clean and simple:

👉 gmaps-scraper

A free, open-source Google Maps scraping tool for everyone.

NPM: https://www.npmjs.com/package/gmaps-scraper

GitHub: https://github.com/Code-Media-Labs/google-maps-scraper


What the Tool Can Do

  • 🔍 Scrape any Google Maps query

  • 🏪 Extract business details (name, rating, reviews, phone, URL)

  • 🔁 Auto-scroll until all results are loaded

  • 🛡 Automatically deduplicate entries

  • 📦 Export results to:

    • results.json
    • results.xlsx
  • 🧰 Use as:

    • A CLI command
    • A Node.js importable library

For freelancers and new agencies, this is a huge time-saver.


How to Use It

Installation

Global (CLI usage):

npm install -g gmaps-scraper
Enter fullscreen mode Exit fullscreen mode

Local (project usage):

npm install gmaps-scraper
Enter fullscreen mode Exit fullscreen mode

CLI Usage

Search for all interior designers in Bhubaneswar:

gmaps-scraper scrape -q "Interior Designers in Bhubaneswar"
Enter fullscreen mode Exit fullscreen mode

Custom output path:

gmaps-scraper scrape -q "Cafes in Cuttack" -o cafes.json 
Enter fullscreen mode Exit fullscreen mode

Headless mode + limited scrolls:

gmaps-scraper scrape -q "Hotels in Puri" --headless -m 50
Enter fullscreen mode Exit fullscreen mode

💻 Library Usage (Node.js)

import { scrapeGoogleMaps } from  "@cml/google-maps-scraper";

const results =  await  scrapeGoogleMaps({

searchQuery:  "Cafes in Cuttack",

outputPath:  "cafes.json",

maxScrollAttempts:  80,

headless:  true,

});

console.log(`Found ${results.length} cafes`);

console.log(results);
Enter fullscreen mode Exit fullscreen mode

Example Output

[  {  "name":  "Urban Café",  "rating":  "4.5",  "reviews_count":  "1,204",  "phone":  "+91 9876543210",  "maps_link":  "https://www.google.com/maps/place/..."  }  ]
Enter fullscreen mode Exit fullscreen mode

Real Talk: Google Maps Can Break Your Selectors

Scraping Google Maps isn't “set-and-forget.”

Google changes:

  • class names

  • container structure

  • layout

  • nested DOM elements

Your selectors may break.

But fixing them is simple if you know what to look for.

Old selector:

const name = await element.$eval('.business-name', el => el.textContent);

Updated selector:

const name = await element.$eval('.place-title span', el => el.textContent);

Whenever Google makes a UI update, just inspect again and adjust your selectors.


Who Should Use This?

This tool is built for anyone who needs structured business data from Google Maps — especially if you’re trying to grow or automate your workflow. You’ll benefit from this scraper if you are:

  • A new agency looking for qualified leads quickly

  • A freelancer who wants to find clients without spending hours searching manually

  • A marketer needing business lists for outreach, campaigns, or segmentation

  • A founder validating a market or researching local competitors

  • An SEO specialist creating or updating business directories

  • A developer building automation tools, dashboards, or datasets

  • A data analyst collecting local business information for insights

If you’re early in your journey and want to save time, remove repetitive work, and scale your lead generation, this tool gives you a massive head start.


What's Coming Next

I’m actively adding:

  • Address, website, and business hours extraction

  • Anti-detection and rate-limiting features

  • Region/language support

  • Cleaner error handling

  • CSV and CRM-friendly output formats

If you want to contribute, PRs are welcome!


Final Thoughts

When you're building a new agency, every hour counts.

This tool saved me countless hours of lead generation — and helped bring in our earliest clients.

That’s why I open-sourced it.

If it helps someone else who’s just starting, it’s worth it.

If you’ve built an internal tool that saved you time… consider open-sourcing it. You might help someone who’s exactly where you were.

And as always, Happy Coding 🧑🏻‍💻

Built with ❤️ by Code Media Labs

Top comments (0)