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.

fix: force UTF-8 on output so the scripts run on Windows

nathanpissinatti12-cell7b1e75a93346
diff --git a/scripts/scrape.py b/scripts/scrape.py
index a669000..6eab26b 100755
--- a/scripts/scrape.py
+++ b/scripts/scrape.py
@@ -26,6 +26,16 @@ Notes:
import argparse, csv, functools, io, json, math, os, re, sys, time, 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
+# names. Windows picks cp1252 for both, so without this the first print raises UnicodeEncodeError
+# before any work happens, and a CSV of scraped names lands in cp1252 instead of UTF-8.
+# errors="replace" keeps a terminal that still cannot render a glyph from killing a finished run.
+for _stream in (sys.stdout, sys.stderr):
+ try:
+ _stream.reconfigure(encoding="utf-8", errors="replace")
+ except (AttributeError, ValueError): # not a reconfigurable stream (pytest capture, a pipe wrapper)
+ pass
+
ENV_KEYS = ("SCRAPER_BASE_URL", "SCRAPER_PORT", "SCRAPER_API_KEY")
@@ -434,10 +444,10 @@ def main():
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'}"
if as_json:
- with open(out, "w") as f:
+ with open(out, "w", encoding="utf-8") as f:
json.dump(results, f, indent=2, ensure_ascii=False)
else:
- with open(out, "w", newline="") as f:
+ with open(out, "w", newline="", encoding="utf-8") as f:
w = csv.DictWriter(f, fieldnames=fields)
w.writeheader()
w.writerows(results)
diff --git a/scripts/scrape.sh b/scripts/scrape.sh
index 90d6fed..35d9c68 100755
--- a/scripts/scrape.sh
+++ b/scripts/scrape.sh
@@ -64,10 +64,11 @@ curl -s ${AUTH[@]+"${AUTH[@]}"} "$BASE/api/v1/jobs/$ID/download" -o "$RAW"
if command -v python3 >/dev/null 2>&1; then
python3 - "$RAW" "$OUT" <<'PY'
import csv, sys
+sys.stdout.reconfigure(encoding='utf-8', errors='replace') # ✓ and accented names vs. cp1252
LEAD = ["title", "phone", "emails", "website", "category", "address", "review_rating", "review_count"]
-with open(sys.argv[1], newline='') as f:
+with open(sys.argv[1], newline='', encoding='utf-8') as f:
rows = list(csv.DictReader(f))
-with open(sys.argv[2], "w", newline='') as f:
+with open(sys.argv[2], "w", newline='', encoding='utf-8') as f:
w = csv.DictWriter(f, fieldnames=LEAD); w.writeheader()
for r in rows:
w.writerow({k: r.get(k, "") for k in LEAD})