Overview
This workflow generates local business leads daily by querying Google for service categories across target cities. It extracts business details from local pack results, deduplicates against existing leads, and outputs new leads for sales outreach. Replaces Google Maps scraping with compliant API-based lead generation at a fraction of the cost.
Trigger
Cron schedule (daily at 8 AM UTC)
Schedule
Runs daily at 8:00 AM UTC
Workflow Steps
Load service-city matrix
Read target services and cities from configuration.
Query Google local results
For each service-city pair, query Scavio Google to get local pack data.
Extract business details
Parse business names, websites, snippets, and rating information.
Deduplicate
Remove businesses already in the lead database.
Output new leads
Write new leads to CRM or CSV for sales team.
Python Implementation
import requests
import json
import csv
from pathlib import Path
API_KEY = "your_scavio_api_key"
def generate_leads(services: list[str], cities: list[str]) -> list[dict]:
seen_path = Path("maps_seen.json")
seen = set(json.loads(seen_path.read_text())) if seen_path.exists() else set()
new_leads = []
for svc in services:
for city in cities:
res = requests.post(
"https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"platform": "google", "query": f"{svc} in {city}"},
timeout=15,
)
if not res.ok:
continue
for r in res.json().get("organic", [])[:10]:
link = r.get("link", "")
if link and link not in seen:
seen.add(link)
new_leads.append({"service": svc, "city": city, "name": r.get("title", ""), "link": link, "snippet": r.get("snippet", "")})
seen_path.write_text(json.dumps(list(seen)))
# Export to CSV
if new_leads:
with open("new_leads.csv", "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=new_leads[0].keys())
writer.writeheader()
writer.writerows(new_leads)
return new_leads
leads = generate_leads(["plumber", "electrician"], ["Austin TX", "Dallas TX", "Houston TX"])
print(f"Generated {len(leads)} new leads")JavaScript Implementation
const API_KEY = "your_scavio_api_key";
async function generateLeads(services, cities) {
const leads = [];
for (const svc of services) {
for (const city of cities) {
const res = await fetch("https://api.scavio.dev/api/v1/search", {
method: "POST",
headers: { "x-api-key": API_KEY, "content-type": "application/json" },
body: JSON.stringify({ platform: "google", query: `${svc} in ${city}` }),
});
if (!res.ok) continue;
for (const r of ((await res.json()).organic ?? []).slice(0, 10)) {
leads.push({ service: svc, city, name: r.title ?? "", link: r.link ?? "" });
}
}
}
console.log(`Generated ${leads.length} leads`);
return leads;
}
await generateLeads(["plumber"], ["Austin TX", "Dallas TX"]);Platforms Used
Web search with knowledge graph, PAA, and AI overviews