Resumen
Este flujo de trabajo exporta local business datos de Google a traves de multiples categoria y city combinations. It consultas Google local resultados for cada combination, extrae business names, ratings, resena counts, y addresses, y compiles everything en un structured conjunto de datos. El salida feeds investigacion de mercado, franchise scouting, y generacion de leads pipelines.
Desencadenador
Manual o programado (semanal)
Programación
Semanal o on-demand
Pasos del flujo de trabajo
Cargar categorias y cities
Leer el matrix of business categorias y objetivo cities de configuracion.
Consulta local resultados for cada combination
For cada category-city pair, call el Scavio API to obtener Google local pack resultados.
Extraer business datos
Analizar local pack resultados to obtener nombre, address, rating, resena conteo, y phone numero.
Deduplicate a traves de consultas
Eliminar duplicate businesses ese appear in multiples categoria searches for el same city.
Exportar to structured formato
Escribir el deduplicated conjunto de datos to JSON y optionally CSV for hoja de calculo importar.
Generar resumen statistics
Calcular promedio ratings, total businesses per city, y cobertura metricas.
Implementacion en Python
import requests
import json
import time
import csv
from pathlib import Path
from datetime import datetime
API_KEY = "your_scavio_api_key"
CATEGORIES = ["coffee shops", "coworking spaces", "gyms", "restaurants"]
CITIES = ["Austin TX", "Denver CO", "Portland OR", "Nashville TN", "Raleigh NC"]
def fetch_local(category: str, city: str) -> list[dict]:
res = requests.post(
"https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"platform": "google", "query": f"{category} in {city}"},
timeout=15,
)
res.raise_for_status()
data = res.json()
businesses = []
for biz in data.get("local_pack", []):
businesses.append({
"name": biz.get("name", ""),
"address": biz.get("address", ""),
"rating": biz.get("rating"),
"reviews": biz.get("reviews", 0),
"phone": biz.get("phone", ""),
"category": category,
"city": city,
})
return businesses
def run():
all_businesses = []
seen = set()
total_queries = len(CATEGORIES) * len(CITIES)
completed = 0
for category in CATEGORIES:
for city in CITIES:
businesses = fetch_local(category, city)
for biz in businesses:
key = f"{biz['name']}_{biz['address']}"
if key not in seen:
seen.add(key)
all_businesses.append(biz)
completed += 1
if completed % 5 == 0:
print(f"Progress: {completed}/{total_queries} queries")
time.sleep(1)
date = datetime.utcnow().strftime("%Y-%m-%d")
# Export JSON
json_path = Path(f"local_businesses_{date}.json")
json_path.write_text(json.dumps(all_businesses, indent=2))
# Export CSV
csv_path = Path(f"local_businesses_{date}.csv")
if all_businesses:
with csv_path.open("w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=all_businesses[0].keys())
writer.writeheader()
writer.writerows(all_businesses)
# Summary
print(f"Export complete: {len(all_businesses)} unique businesses")
print(f" Categories: {len(CATEGORIES)} | Cities: {len(CITIES)}")
print(f" Avg rating: {sum(b['rating'] for b in all_businesses if b['rating']) / max(1, sum(1 for b in all_businesses if b['rating'])):.1f}")
if __name__ == "__main__":
run()Implementacion en JavaScript
const API_KEY = "your_scavio_api_key";
const CATEGORIES = ["coffee shops", "coworking spaces", "gyms", "restaurants"];
const CITIES = ["Austin TX", "Denver CO", "Portland OR", "Nashville TN", "Raleigh NC"];
async function fetchLocal(category, city) {
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: `${category} in ${city}` }),
});
if (!res.ok) throw new Error(`scavio ${res.status}`);
const data = await res.json();
return (data.local_pack ?? []).map((biz) => ({
name: biz.name ?? "",
address: biz.address ?? "",
rating: biz.rating ?? null,
reviews: biz.reviews ?? 0,
phone: biz.phone ?? "",
category,
city,
}));
}
async function run() {
const fs = await import("fs/promises");
const allBusinesses = [];
const seen = new Set();
let completed = 0;
const total = CATEGORIES.length * CITIES.length;
for (const category of CATEGORIES) {
for (const city of CITIES) {
const businesses = await fetchLocal(category, city);
for (const biz of businesses) {
const key = `${biz.name}_${biz.address}`;
if (!seen.has(key)) {
seen.add(key);
allBusinesses.push(biz);
}
}
completed++;
if (completed % 5 === 0) {
console.log(`Progress: ${completed}/${total} queries`);
await new Promise((r) => setTimeout(r, 1000));
}
}
}
const date = new Date().toISOString().slice(0, 10);
await fs.writeFile(`local_businesses_${date}.json`, JSON.stringify(allBusinesses, null, 2));
// CSV export
if (allBusinesses.length) {
const header = Object.keys(allBusinesses[0]).join(",");
const rows = allBusinesses.map((b) => Object.values(b).map((v) => `"${String(v ?? "").replace(/"/g, '""')}"`).join(","));
await fs.writeFile(`local_businesses_${date}.csv`, [header, ...rows].join("\n"));
}
const rated = allBusinesses.filter((b) => b.rating);
const avgRating = rated.length ? rated.reduce((s, b) => s + b.rating, 0) / rated.length : 0;
console.log(`Export: ${allBusinesses.length} unique businesses | Avg rating: ${avgRating.toFixed(1)}`);
}
run();Plataformas utilizadas
Búsqueda web con grafo de conocimiento, PAA y resúmenes de IA