Skip to content

Free, open-source Google Maps scraper for lead generation (Python, no API key, no Docker). Exports name, phone, email, website, rating and Instagram/Facebook/LinkedIn/TikTok/YouTube/X links to CSV. 100 places with emails in 44 s; --grid beats Google's 120 cap. MX email check, ad-pixel detection. Skill for Claude Code, Codex and Cursor.

feat: --tech ad signals and intent score, safer site fetches, better emails (#28)

Mahan Ai22e624730da8
diff --git a/.claude/skills/google-maps-scraper/SKILL.md b/.claude/skills/google-maps-scraper/SKILL.md
index c2811cd..cbb7c34 100644
--- a/.claude/skills/google-maps-scraper/SKILL.md
+++ b/.claude/skills/google-maps-scraper/SKILL.md
@@ -140,6 +140,15 @@ grid is slower and more likely to trip rate limits: warn once, don't block.
**Deep email pass:** on by default whenever emails are on. Rows with a website but no email get their
contact and about pages checked, and the script prints the found rate. `--no-deep-emails` skips it.
+**Who already advertises:** when the user wants warm leads, businesses that run ads, or to know a
+site's platform, add `--tech`. It reads each homepage for a Meta Pixel, Google Ads tag and analytics,
+the platform (WordPress, Shopify, Wix, Squarespace, Webflow) and mobile support, scores each lead 0-100
+(`intent_score`: pixels dominate, reviews, rating and an email add a little) and sorts highest first.
+It finds installed tags, not live ad campaigns. Zero LLM tokens.
+
+The script fetches only public addresses: a website that resolves or redirects to a private,
+loopback or link-local address (this machine, the engine on localhost, the user's network) is skipped.
+
## Other endpoints
- `GET /api/v1/jobs` lists jobs. `DELETE /api/v1/jobs/{id}` deletes a job and frees disk.
- Browser UI and OpenAPI docs: `http://localhost:8080` and `http://localhost:8080/api/docs`. The kit's
diff --git a/CREDITS.md b/CREDITS.md
index 16ee377..1e02603 100644
--- a/CREDITS.md
+++ b/CREDITS.md
@@ -17,6 +17,13 @@ The kit runs the engine's official Docker image, unmodified. Everything else in
original to the kit: local deployment, lead-field cleaning, CSV output, auto-geocoding, batch jobs,
social profile enrichment, and the Claude Code skill and slash commands.
+## Website signals adapted from OpenLeadFinder
+
+The `--tech` detection patterns, the intent score and the obfuscated-email patterns in
+`scripts/scrape.py`, and its private-address guard, are adapted from OpenLeadFinder, Mahan's
+self-hosted lead finder. It is released under the same MIT License, Copyright (c) 2026
+OpenLeadFinder contributors; the license text is the one reproduced below.
+
## Engine license (reproduced as required by MIT)
```
diff --git a/README.md b/README.md
index 47dce10..f6fad02 100644
--- a/README.md
+++ b/README.md
@@ -91,8 +91,10 @@ python3 scripts/scrape.py "dentists in Denver CO" --city "Denver, CO" --grid 3
| Example Roasters | +1 512-555-0101 | [email protected] | example.com | Coffee shop | 100 Congress Ave, Austin, TX | 4.7 | 812 |
| Sample Espresso Bar | +1 512-555-0102 | [email protected] | example.org | Cafe | 200 S Lamar Blvd, Austin, TX | 4.5 | 356 |
-`--socials` adds `instagram`, `facebook` and `linkedin` columns. `--full` keeps all 36 raw fields,
-including opening hours, coordinates, price range and reviews.
+`--socials` adds `instagram`, `facebook` and `linkedin` columns. `--tech` adds `fb_pixel`,
+`google_ads_tag`, `analytics`, `cms`, `mobile_friendly` and `intent_score`, and sorts the hottest
+leads first. `--full` keeps all 36 raw fields, including opening hours, coordinates, price range and
+reviews.
Full walkthrough, platform notes and troubleshooting: [SETUP.md](SETUP.md).
@@ -144,8 +146,9 @@ scrapes Google Maps business listings only. It does not scrape social platforms
| **Email extraction, on by default** | Visits each business website and pulls published contact emails. A second pass checks the contact and about pages of rows still missing one, then prints your found rate. |
| **Beyond the 120 cap** | `--grid 3` splits the city into 3 x 3 map tiles, runs them one at a time and dedupes on `place_id`. |
| **Social enrichment** | `--socials` finds Instagram, Facebook and LinkedIn profiles in code (HTTP + regex). Zero AI tokens. |
+| **Who already advertises** | `--tech` spots a Meta Pixel, Google Ads tag and analytics on each website, plus its platform (WordPress, Shopify, Wix…) and mobile support, then ranks leads by an `intent_score` from 0 to 100. Zero AI tokens. |
| **Auto-geocoding** | Type a city name. Coordinates are resolved for you via OpenStreetMap. |
-| **Batch jobs** | Many keywords, one job, one CSV. |
+| **Batch jobs** | Many keywords, one job, one CSV. The engine lists a place found by several keywords once. |
| **Proxy rotation** | Built into the engine for large or repeated runs. `socks5`, `socks5h`, `http`, `https`. |
| **Agent-native** | A skill plus four slash commands. The agent handles create, poll, download, clean and present. |
| **Safe defaults** | API bound to `127.0.0.1`, results git-ignored, rate-limit and data-law guardrails built into the skill. |
diff --git a/docs/google-maps-scraper-python.md b/docs/google-maps-scraper-python.md
index d86443e..9b696a9 100644
--- a/docs/google-maps-scraper-python.md
+++ b/docs/google-maps-scraper-python.md
@@ -33,6 +33,7 @@ On Windows, run the same commands with `py` or `python3`. Python is only the cli
| `--full` | Keeps all 36 raw columns instead of the 8 lead fields. |
| `--fields` | Comma-separated columns to keep, overriding the lead fields. |
| `--socials` | Adds Instagram, Facebook and LinkedIn from each website. Slower. Zero AI tokens. |
+| `--tech` | Adds `fb_pixel`, `google_ads_tag`, `analytics` (yes/no, blank if the site did not load), `cms`, `mobile_friendly` and a 0-100 `intent_score`, and sorts by that score. Shares the homepage fetch with `--socials`. Zero AI tokens. |
| `--keyword` | Adds an extra keyword to the same job. Repeatable. |
| `--keywords-file` | Reads one keyword per line from a file. One job, one CSV. |
diff --git a/scripts/scrape.py b/scripts/scrape.py
index bf7b10d..9f70559 100755
--- a/scripts/scrape.py
+++ b/scripts/scrape.py
@@ -23,7 +23,8 @@ Notes:
- Geocoding uses OpenStreetMap Nominatim (free, no key). It allows ~1 request/sec and requires a
descriptive User-Agent (set below). Do not loop it aggressively.
"""
-import argparse, csv, functools, io, json, math, os, re, sys, time, urllib.request, urllib.parse, urllib.error
+import argparse, csv, functools, io, ipaddress, json, math, os, re, socket, sys, time
+import html as _html, urllib.request, urllib.parse, urllib.error
from concurrent.futures import ThreadPoolExecutor
# The status lines below use ▶ ✓ ℹ •, and every file this script writes can hold accented business
@@ -59,7 +60,7 @@ KEY = os.environ.get("SCRAPER_API_KEY", "")
# The 8 lead fields: what you use to contact and qualify a lead.
# Everything else (geo coordinates, IDs, hours, images, review blobs) is dropped by default.
LEAD = ["title", "phone", "emails", "website", "category", "address", "review_rating", "review_count"]
-UA = "google-maps-scraper-kit/1.2 (https://github.com/Mahanaicoach/google-maps-scraper-kit)"
+UA = "google-maps-scraper-kit/1.3 (https://github.com/Mahanaicoach/google-maps-scraper-kit)"
POLL_EVERY = 8 # seconds between status checks
POLL_GRACE = 120 # the engine still has to flush results and flip the status
@@ -221,32 +222,57 @@ SOCIAL_RE = {
"facebook": re.compile(r"https?://(?:www\.|m\.|web\.)?facebook\.com/([A-Za-z0-9_.\-]+)", re.I),
"linkedin": re.compile(r"https?://(?:[a-z]{2,3}\.)?linkedin\.com/(?:company|in|school)/([A-Za-z0-9_.\-%]+)", re.I),
}
+SOCIAL_FIELDS = list(SOCIAL_RE)
_SKIP_HANDLE = {"", "home", "pages", "people", "help", "about", "policies", "policy",
"legal", "tos", "privacy", "settings", "sharer", "tr", "profile.php",
"plugins", "dialog", "intent", "login", "share.php", "permalink.php",
"p", "reel", "reels", "explore", "stories", "tv", "watch", "events",
"groups", "marketplace", "gaming", "photo", "hashtag", "search"}
[email protected]_cache(maxsize=1024)
+def _is_public_host(host):
+ """True only if every address the host resolves to is public. Websites come from third-party
+ listings, so one could point a fetch at this machine or its network instead (the engine API on
+ localhost:8080, a router admin page, a cloud metadata endpoint)."""
+ try:
+ infos = socket.getaddrinfo(host, None)
+ return bool(infos) and all(ipaddress.ip_address(i[4][0].split("%")[0]).is_global for i in infos)
+ except (OSError, UnicodeError, ValueError):
+ return False
+
+class _PublicRedirectsOnly(urllib.request.HTTPRedirectHandler):
+ """A public site may not redirect the fetch to a private address either."""
+ def redirect_request(self, req, fp, code, msg, headers, newurl):
+ if not _is_public_host(urllib.parse.urlparse(newurl).hostname or ""):
+ return None # urllib then raises HTTPError, which _fetch_html turns into ""
+ return super().redirect_request(req, fp, code, msg, headers, newurl)
+
+_OPENER = urllib.request.build_opener(_PublicRedirectsOnly)
+
def _fetch_html(url, timeout=10):
if not url:
return ""
if not url.startswith(("http://", "https://")):
url = "http://" + url
+ # ponytail: the host is resolved again by the actual connect, so DNS rebinding can still slip
+ # through; pin the checked IP in a custom connection if this ever runs as a shared service.
+ if not _is_public_host(urllib.parse.urlparse(url).hostname or ""):
+ return ""
try:
r = urllib.request.Request(url, headers={
"User-Agent": "Mozilla/5.0 (compatible; " + UA + ")", "Accept": "text/html"})
- with urllib.request.urlopen(r, timeout=timeout) as resp:
+ with _OPENER.open(r, timeout=timeout) as resp:
return resp.read(400_000).decode("utf-8", "replace")
except Exception:
return ""
@functools.lru_cache(maxsize=512) # ponytail: homepages only; evicted pages just refetch
def _fetch_cached(url):
- """Homepage fetch shared by the deep email pass and --socials (one fetch per site)."""
+ """Homepage fetch shared by the deep email pass, --socials and --tech (one fetch per site)."""
return _fetch_html(url, timeout=8)
def _find_socials(html):
- out = {"instagram": "", "facebook": "", "linkedin": ""}
+ out = {k: "" for k in SOCIAL_FIELDS}
for plat, rx in SOCIAL_RE.items():
for m in rx.finditer(html or ""):
h = m.group(1).lower()
@@ -258,21 +284,68 @@ def _find_socials(html):
break
return out
-def enrich_socials(results, workers=8):
- """Add instagram/facebook/linkedin to each lead by scanning its website. Zero LLM tokens."""
+def enrich_sites(results, find, fields, label, workers=8):
+ """Merge find(homepage html) into every lead that has a website. Zero LLM tokens."""
for r in results: # make sure every row has the keys
- r.setdefault("instagram", ""); r.setdefault("facebook", ""); r.setdefault("linkedin", "")
+ for k in fields:
+ r.setdefault(k, "")
todo = [r for r in results if r.get("website")]
done = 0
def work(r):
- r.update(_find_socials(_fetch_cached(r["website"])))
+ r.update(find(_fetch_cached(r["website"])))
with ThreadPoolExecutor(max_workers=workers) as ex:
for _ in ex.map(work, todo):
done += 1
- print(f"\r socials: {done}/{len(todo)} sites checked", end="", flush=True)
+ print(f"\r {label}: {done}/{len(todo)} sites checked", end="", flush=True)
print()
+# ── Optional ad and tech signals (--tech): who already spends on marketing ──────
+# Regexes from OpenLeadFinder's website layer. They run on the homepage already fetched above.
+TECH_RE = {
+ "fb_pixel": re.compile(r"connect\.facebook\.net/[^\"']*fbevents\.js|fbq\(", re.I),
+ "google_ads_tag": re.compile(r"googleadservices\.com|AW-\d{6,}|googleads\.g\.doubleclick\.net", re.I),
+ "analytics": re.compile(r"googletagmanager\.com/gtag|gtag\(|UA-\d{4,}|G-[A-Z0-9]{6,}", re.I),
+}
+CMS_RE = [
+ ("wordpress", re.compile(r"/wp-content/|/wp-includes/", re.I)),
+ ("shopify", re.compile(r"cdn\.shopify\.com|shopify\.theme", re.I)),
+ ("wix", re.compile(r"static\.wixstatic\.com|_wixcss|wix\.com", re.I)),
+ ("squarespace", re.compile(r"static1\.squarespace|squarespace\.com", re.I)),
+ ("webflow", re.compile(r"webflow\.com", re.I)),
+]
+VIEWPORT_RE = re.compile(r"<meta[^>]+name=[\"']viewport[\"']", re.I)
+TECH_FIELDS = list(TECH_RE) + ["cms", "mobile_friendly"]
+
+def _find_tech(html):
+ """yes/no per signal, the site platform, and mobile support. Blank when the site did not load,
+ so "unknown" never reads as "no pixel"."""
+ if not html:
+ return {k: "" for k in TECH_FIELDS}
+ yn = lambda hit: "yes" if hit else "no"
+ out = {k: yn(rx.search(html)) for k, rx in TECH_RE.items()}
+ out["cms"] = next((name for name, rx in CMS_RE if rx.search(html)), "")
+ out["mobile_friendly"] = yn(VIEWPORT_RE.search(html))
+ return out
+
+def _num(v, kind=float):
+ try:
+ return kind(str(v).replace(",", ""))
+ except ValueError:
+ return 0
+
+def intent_score(r):
+ """0-100 "already spends on marketing" score: ad pixels dominate, an established, reachable
+ business adds a little. A heuristic, adapted from OpenLeadFinder without its live ad checks."""
+ s = 35 * (r.get("fb_pixel") == "yes") + 25 * (r.get("google_ads_tag") == "yes")
+ s += 10 * (r.get("analytics") == "yes")
+ reviews = _num(r.get("review_count"), int)
+ s += 15 if reviews >= 50 else 8 if reviews >= 10 else 0
+ s += 10 * (_num(r.get("review_rating")) >= 4.0)
+ s += 5 * bool(r.get("emails"))
+ return s
+
+
# ── Deep email pass: contact/about pages for rows the engine left without an email ──
EMAIL_RE = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")
MAILTO_RE = re.compile(r"mailto:([^\"'>\s?]+)", re.I)
@@ -319,11 +392,23 @@ def clean_engine_emails(results):
return changed
+# "name [at] domain [dot] com", "name (at) domain dot com" and friends, adapted from OpenLeadFinder.
+# The "at" must be bracketed and the domain must end in a known TLD: a bare " at " also matched
+# prose such as "meet at noon dot com".
+_AT = r"(?:\[\s*at\s*\]|\(\s*at\s*\)|\{\s*at\s*\})"
+_DOT = r"(?:\[\s*dot\s*\]|\(\s*dot\s*\)|\{\s*dot\s*\}|\s+dot\s+)"
+_TLD = (r"(?:com|net|org|co|io|biz|info|us|uk|ca|au|de|fr|es|it|nl|eu|edu|gov|me|app|dev|"
+ r"shop|online|store|xyz|ai)")
+_DEOBF_RE = re.compile(rf"([A-Za-z0-9._%+\-]+)\s*{_AT}\s*([A-Za-z0-9.\-]+?)\s*{_DOT}\s*({_TLD})\b", re.I)
+
def extract_emails(html, site_host):
- """Emails from mailto: links and plain text, junk dropped, site-domain first, max 3."""
+ """Emails from mailto: links, plain text and obfuscated spans, junk dropped, site-domain first,
+ max 3. HTML entities are decoded first, so info&#64;site.com counts."""
site = _host(site_host or "")
+ text = _html.unescape(html or "")
found = []
- for e in MAILTO_RE.findall(html or "") + EMAIL_RE.findall(html or ""):
+ deobf = [f"{m[0]}@{m[1]}.{m[2]}" for m in _DEOBF_RE.findall(text)]
+ for e in MAILTO_RE.findall(text) + EMAIL_RE.findall(text) + deobf:
e = _ESCAPE_PREFIX.sub("", urllib.parse.unquote(e).strip().lower())
if not is_real_email(e) or e in found:
continue
@@ -403,6 +488,9 @@ def main():
ap.add_argument("--fields", help="comma-separated columns to keep (overrides the default lead set)")
ap.add_argument("--socials", action="store_true",
help="also find Instagram/Facebook/LinkedIn from each website (0 LLM tokens; slower)")
+ ap.add_argument("--tech", action="store_true",
+ help="also detect Meta Pixel, Google Ads tag, analytics, site platform and mobile "
+ "support on each website, and sort by an intent_score (0 LLM tokens; slower)")
a = ap.parse_args()
keywords = collect_keywords(a)
@@ -515,11 +603,22 @@ def main():
print("▶ Finding socials (Instagram / Facebook / LinkedIn) on each website…")
print(" ℹ Cost: this runs in CODE = 0 LLM tokens. It only adds ~40–50 tokens per business")
print(" IF you load the results into an AI's context (negligible if you keep the file on disk).")
- enrich_socials(results)
- fields = fields + ["instagram", "facebook", "linkedin"]
- found = sum(1 for r in results if r.get("instagram") or r.get("facebook") or r.get("linkedin"))
+ enrich_sites(results, _find_socials, SOCIAL_FIELDS, "socials")
+ fields = fields + SOCIAL_FIELDS
+ found = sum(1 for r in results if any(r.get(k) for k in SOCIAL_FIELDS))
print(f" socials found for {found}/{len(results)} businesses")
+ if a.tech:
+ print("▶ Checking ad pixels, analytics and site platform on each website (0 LLM tokens)…")
+ enrich_sites(results, _find_tech, TECH_FIELDS, "tech")
+ for r in results:
+ r["intent_score"] = intent_score(r)
+ results.sort(key=lambda r: r["intent_score"], reverse=True)
+ fields = fields + TECH_FIELDS + ["intent_score"]
+ ads = sum(1 for r in results if "yes" in (r.get("fb_pixel"), r.get("google_ads_tag")))
+ print(f" Meta Pixel or Google Ads tag on {ads}/{len(results)} websites; "
+ f"rows sorted by intent_score (highest first)")
+
# Default output is a CSV file (opens in Excel / Google Sheets). Use --json (or a .json --out path) for JSON.
as_json = a.json or (a.out and a.out.lower().endswith(".json"))
out = a.out or f"results-{job_id[:8]}.{'json' if as_json else 'csv'}"
diff --git a/scripts/test_scrape.py b/scripts/test_scrape.py
index f30ada8..b074a6d 100644
--- a/scripts/test_scrape.py
+++ b/scripts/test_scrape.py
@@ -127,6 +127,50 @@ class ExtractEmails(unittest.TestCase):
self.assertEqual(scrape.extract_emails("", "x.com"), [])
self.assertEqual(scrape.extract_emails("no emails here", "x.com"), [])
+ def test_entities_and_obfuscation(self):
+ html = "Mail info&#64;acme.com, jane [at] acme [dot] com or bob (at) acme dot co"
+ self.assertEqual(scrape.extract_emails(html, "acme.com"),
+
+ def test_prose_is_not_an_email(self):
+ self.assertEqual(scrape.extract_emails("Meet us at noon dot com, look at me dot org", "x.com"), [])
+
+
+class PublicHostGuard(unittest.TestCase):
+ def test_private_addresses_blocked(self):
+ for host in ("localhost", "127.0.0.1", "10.0.0.5", "192.168.1.1", "169.254.169.254", "::1", ""):
+ self.assertFalse(scrape._is_public_host(host), host)
+ self.assertTrue(scrape._is_public_host("8.8.8.8"))
+
+ def test_fetch_refuses_local_engine(self):
+ with mock.patch.object(scrape._OPENER, "open") as opened:
+ self.assertEqual(scrape._fetch_html("http://localhost:8080/api/v1/jobs"), "")
+ opened.assert_not_called()
+
+ def test_redirect_to_private_address_refused(self):
+ handler = scrape._PublicRedirectsOnly()
+ req = scrape.urllib.request.Request("http://8.8.8.8/")
+ self.assertIsNone(handler.redirect_request(req, None, 302, "Found", {}, "http://127.0.0.1/admin"))
+
+
+class TechSignals(unittest.TestCase):
+ def test_detects_pixel_platform_viewport(self):
+ html = ('<script src="https://connect.facebook.net/en_US/fbevents.js"></script>'
+ '<meta name="viewport" content="width=device-width"><link href="/wp-content/a.css">'
+ "<script>gtag('config','AW-123456789')</script>")
+ self.assertEqual(scrape._find_tech(html), {"fb_pixel": "yes", "google_ads_tag": "yes",
+ "analytics": "yes", "cms": "wordpress", "mobile_friendly": "yes"})
+
+ def test_unreachable_site_is_unknown_not_no(self):
+ self.assertEqual(set(scrape._find_tech("").values()), {""})
+
+ def test_intent_score(self):
+ hot = {"fb_pixel": "yes", "google_ads_tag": "yes", "analytics": "yes",
+ "review_count": "1,204", "review_rating": "4.6", "emails": "[email protected]"}
+ self.assertEqual(scrape.intent_score(hot), 100)
+ self.assertEqual(scrape.intent_score({}), 0)
+ self.assertEqual(scrape.intent_score({"review_count": "12", "review_rating": "n/a"}), 8)
+
class CleanEngineEmails(unittest.TestCase):
def test_drops_placeholders_keeps_real(self):