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.
Python agent-skillsb2b-leadsclaude-codeclaude-skillscodex-skillsemail-extractoremail-scrapergoogle-mapsgoogle-maps-extractorgoogle-maps-leadsgoogle-maps-scrapergoogle-maps-scraper-pythongoogle-maps-scrapinggooglemaps-scraperheadless-chromelead-generationlead-scraperno-api-keypythonweb-scraping
fix: filter placeholder emails the engine returns, so the found rate is honest
nathanpissinatti12-cell5f4e11c63980
diff --git a/scripts/scrape.py b/scripts/scrape.pyindex a669000..8c2c389 100755--- a/scripts/scrape.py+++ b/scripts/scrape.py@@ -236,7 +236,8 @@ HREF_RE = re.compile(r"<a\s[^>]*?href\s*=\s*[\"']([^\"']+)[\"'][^>]*>(.*?)</a>",_JUNK_EXT = (".png", ".jpg", ".jpeg", ".gif", ".svg", ".webp", ".css", ".js")_JUNK_DOMAIN = ("example", "sentry", "wixpress", "wix.com", "godaddy", "squarespace", "wordpress","domain.com", "email.com", "yourdomain", "schema.org", "w3.org", "sentry.io")-_JUNK_LOCAL = {"name", "email", "user", "you", "someone"}+_JUNK_LOCAL = {"name", "email", "user", "you", "someone", "example", "username",+ "youremail", "yourname", "firstname", "lastname", "sample"}def _host(url):if not url.startswith(("http://", "https://")):@@ -244,15 +245,39 @@ def _host(url):h = (urllib.parse.urlparse(url).hostname or "").lower()return h[4:] if h.startswith("www.") else h+def is_real_email(e):+ """False for anything not worth sending to: a template placeholder ([email protected],+ [email protected]), a vendor/boilerplate domain, or an image path that parsed as an address."""+ local, _, dom = e.rpartition("@")+ if not EMAIL_RE.fullmatch(e) or e.endswith(_JUNK_EXT):+ return False+ return local not in _JUNK_LOCAL and not any(j in dom for j in _JUNK_DOMAIN)+++def clean_engine_emails(results):+ """Re-filter the engine's own `emails` column through is_real_email.++ The engine copies whatever it finds on the page, placeholders included, and until now only the+ addresses this script scraped itself were filtered. That let [email protected] through and counted+ it as a hit, so the found rate printed below overstated how many leads were reachable.+ Returns the number of rows changed; a row left empty here still gets the deep pass."""+ changed = 0+ for r in results:+ raw = [e.strip().lower() for e in (r.get("emails") or "").split(",") if e.strip()]+ kept = list(dict.fromkeys(e for e in raw if is_real_email(e)))+ if kept != raw:+ r["emails"] = ", ".join(kept)+ changed += 1+ return changed++def extract_emails(html, site_host):"""Emails from mailto: links and plain text, junk dropped, site-domain first, max 3."""site = _host(site_host or "")found = []for e in MAILTO_RE.findall(html or "") + EMAIL_RE.findall(html or ""):e = urllib.parse.unquote(e).strip().lower()- local, _, dom = e.rpartition("@")- if (not EMAIL_RE.fullmatch(e) or e.endswith(_JUNK_EXT) or local in _JUNK_LOCAL- or any(j in dom for j in _JUNK_DOMAIN) or e in found):+ if not is_real_email(e) or e in found:continuefound.append(e)on_site = lambda e: site and (e.endswith("@" + site) or e.endswith("." + site))@@ -412,6 +437,11 @@ def main():results = [{k: r.get(k, "") for k in fields} for r in rows]print(f"✓ Done — {len(results)} businesses (fields: {', '.join(fields)}).")+ if "emails" in fields:+ dropped = clean_engine_emails(results)+ if dropped:+ print(f" dropped placeholder emails ([email protected] and the like) on {dropped} row(s)")+if a.email and a.deep_emails and "emails" in fields:print("▶ Deep email pass: checking contact/about pages for rows with no email…")engine = sum(1 for r in results if r.get("emails"))diff --git a/scripts/test_scrape.py b/scripts/test_scrape.pyindex 0588f1d..efd1349 100644--- a/scripts/test_scrape.py+++ b/scripts/test_scrape.py@@ -85,6 +85,34 @@ class ExtractEmails(unittest.TestCase):self.assertEqual(scrape.extract_emails("no emails here", "x.com"), [])+class CleanEngineEmails(unittest.TestCase):+ def test_drops_placeholders_keeps_real(self):+ # The left column is what the engine actually returned on a depth 1 Austin scrape.+ rows = [{"emails": "[email protected]"},+ {"emails": "[email protected], [email protected]"},+ {"emails": "[email protected]"},+ {"emails": ""}]+ changed = scrape.clean_engine_emails(rows)+ self.assertEqual([r["emails"] for r in rows],+ ["", "[email protected]", "[email protected]",+ "[email protected]", ""])+ self.assertEqual(changed, 3) # untouched rows are not counted++ def test_missing_column_is_not_an_error(self):+ rows = [{"title": "no emails field"}]+ self.assertEqual(scrape.clean_engine_emails(rows), 0)+++class IsRealEmail(unittest.TestCase):+ def test_placeholders_and_vendors(self):+ self.assertFalse(scrape.is_real_email(e), e)+ self.assertTrue(scrape.is_real_email(e), e)++class ContactLinks(unittest.TestCase):def test_discovers_same_site_only(self):html = """<a href="/contact-us#form">Get in touch</a>