Resumen
Rastrear competidor producto prices on Google Shopping diario usando un search API instead of maintaining proxy infrastructure. El flujo de trabajo consultas Google Shopping for objetivo productos, extrae actual prices, compara contra almacenado baselines, y envia alertas cuando prices cambio mas alla de un umbral.
Desencadenador
Diario cron at 06:00 UTC
Programación
Diario at 06:00 UTC
Pasos del flujo de trabajo
Cargar producto watchlist
Leer el lista of producto consultas y their last-known prices de un JSON file o base de datos.
Consulta Google Shopping
For cada producto, enviar un consulta de busqueda to el Google Shopping plataforma endpoint y extraer el top 5 resultados con prices.
Comparar contra linea base
Verificar cada returned price contra el almacenado linea base. Marcar productos donde el price changed by mas than 5%.
Actualizar linea base
Escribir el nuevo prices back to storage con marcas de tiempo for historico seguimiento.
Enviar alertas
For flagged productos, enviar un Slack o correo electronico notificacion con el old price, nuevo price, y porcentaje cambio.
Implementacion en Python
import requests, json, os
from datetime import datetime
H = {"x-api-key": os.environ["SCAVIO_API_KEY"], "Content-Type": "application/json"}
def monitor_prices(watchlist_path="watchlist.json"):
with open(watchlist_path) as f:
watchlist = json.load(f)
alerts = []
for item in watchlist:
r = requests.post("https://api.scavio.dev/api/v1/search", headers=H,
json={"platform": "google_shopping", "query": item["query"]}).json()
results = r.get("shopping_results", [])[:5]
if not results:
continue
current_price = min(float(r.get("price", "999999").replace("$", "").replace(",", ""))
for r in results if r.get("price"))
if item.get("baseline"):
change = (current_price - item["baseline"]) / item["baseline"] * 100
if abs(change) > 5:
alerts.append({"product": item["query"], "old": item["baseline"],
"new": current_price, "change_pct": round(change, 1)})
item["baseline"] = current_price
item["updated"] = datetime.now().isoformat()
with open(watchlist_path, "w") as f:
json.dump(watchlist, f, indent=2)
return alerts
alerts = monitor_prices()
for a in alerts:
print(f"{a['product']}: ${a['old']} -> ${a['new']} ({a['change_pct']}%)")Implementacion en JavaScript
const H = {"x-api-key": process.env.SCAVIO_API_KEY, "Content-Type": "application/json"};
const fs = require("fs");
async function monitorPrices(watchlistPath = "watchlist.json") {
const watchlist = JSON.parse(fs.readFileSync(watchlistPath, "utf8"));
const alerts = [];
for (const item of watchlist) {
const r = await fetch("https://api.scavio.dev/api/v1/search", {
method: "POST", headers: H,
body: JSON.stringify({platform: "google_shopping", query: item.query})
}).then(r => r.json());
const results = (r.shopping_results || []).slice(0, 5);
if (!results.length) continue;
const prices = results.filter(r => r.price).map(r =>
parseFloat(r.price.replace("$", "").replace(",", "")));
const currentPrice = Math.min(...prices);
if (item.baseline) {
const change = (currentPrice - item.baseline) / item.baseline * 100;
if (Math.abs(change) > 5) {
alerts.push({product: item.query, old: item.baseline,
new: currentPrice, changePct: Math.round(change * 10) / 10});
}
}
item.baseline = currentPrice;
item.updated = new Date().toISOString();
}
fs.writeFileSync(watchlistPath, JSON.stringify(watchlist, null, 2));
return alerts;
}
monitorPrices().then(alerts =>
alerts.forEach(a => console.log(`${a.product}: $${a.old} -> $${a.new} (${a.changePct}%)`))
);