[object Object]

← back to Commercialrealestate

condos: weekly auto-scrape of NEW-listing brokers (--only-missing) + log Browserbase spend to cost-ledger for AbramsEgo budget tracking

de3b47794637c62fe77b2b5cc1552b322f8614a8 · 2026-08-03 08:57:24 -0700 · Steve Abrams

Files touched

Diff

commit de3b47794637c62fe77b2b5cc1552b322f8614a8
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Aug 3 08:57:24 2026 -0700

    condos: weekly auto-scrape of NEW-listing brokers (--only-missing) + log Browserbase spend to cost-ledger for AbramsEgo budget tracking
---
 scripts/enrich-condo-brokers.js | 11 ++++++++++-
 scripts/run-condos-report.sh    |  8 +++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/scripts/enrich-condo-brokers.js b/scripts/enrich-condo-brokers.js
index 8442b3e..544d465 100644
--- a/scripts/enrich-condo-brokers.js
+++ b/scripts/enrich-condo-brokers.js
@@ -187,7 +187,16 @@ async function main() {
   if (browser) await browser.close();
   if (bbSession) {
     const mins = (Date.now() - startedAt) / 60000;
-    console.log(`  Browserbase session ~${mins.toFixed(1)} min → est $${(mins * 0.15).toFixed(2)} (@ $0.15/session-min, + proxy bandwidth)`);
+    const cost = +(mins * 0.15).toFixed(2);
+    console.log(`  Browserbase session ~${mins.toFixed(1)} min → est $${cost.toFixed(2)} (@ $0.15/session-min, + proxy bandwidth)`);
+    // Log to the shared cost-ledger so AbramsEgo (:9773) tracks this spend against its budget.
+    try {
+      const row = { ts: new Date().toISOString(), api: 'browserbase', vendor: 'Browserbase',
+        app: 'commercialrealestate/enrich-condo-brokers', note: `condo broker Redfin scrape (${gotBroker} listings, ${mins.toFixed(1)} session-min)`,
+        units: [{ qty: +mins.toFixed(2), unit: 'session_min', rate: 0.15, subtotal: cost }], cost_usd: cost };
+      fs.appendFileSync(path.join(process.env.HOME, '.claude', 'cost-ledger.jsonl'), JSON.stringify(row) + '\n');
+      console.log('  ✔ logged to cost-ledger (AbramsEgo budget tracking)');
+    } catch (e) { console.log('  (cost-ledger log skipped:', e.message, ')'); }
   }
 
   // Merge into canonical condos-redfin.json (backup first; ADD-only by id).
diff --git a/scripts/run-condos-report.sh b/scripts/run-condos-report.sh
index 24e2370..7a54c83 100755
--- a/scripts/run-condos-report.sh
+++ b/scripts/run-condos-report.sh
@@ -14,7 +14,13 @@ echo "===== condos run $(date) =====" >> "$LOG"
 #    down we still build + email off the last classified snapshot so the report always goes out.
 /opt/homebrew/bin/node scripts/fetch-condos-redfin.js >> "$LOG" 2>&1 || echo "fetch-condos-redfin failed (continuing on last snapshot)" >> "$LOG"
 
-# 2) Build the unwarrantable-condos HTML (fha_expired only).
+# 1.5) Enrich NEW listings with broker + firm + DRE# + phones (--only-missing: only listings without
+#       broker data are scraped — usually a handful/week, so cost stays low). The DRE# is hooked into
+#       the full CA DRE record. Non-fatal. Logs its Browserbase spend to the cost-ledger, which
+#       AbramsEgo (:9773) tracks against budget.
+/opt/homebrew/bin/node scripts/enrich-condo-brokers.js --only-missing --browserbase --delay 900 >> "$LOG" 2>&1 || echo "enrich-condo-brokers failed (continuing; report falls back to Redfin deep links)" >> "$LOG"
+
+# 2) Build the unwarrantable-condos HTML (fha_expired only; overlays the persistent broker cache).
 REPORT_DATE="$(date +%Y-%m-%d)" /opt/homebrew/bin/node scripts/condos-report.js > data/condos-report.html 2>> "$LOG"
 
 # 3) Email the report as-is (separate from the multifamily CRE Top-10).

← 3a288f6 auto-save: 2026-08-03T08:52:19 (1 files) — data/condos-repor  ·  back to Commercialrealestate  ·  fetch-condos-redfin: log Browserbase spend to cost-ledger fo 640b812 →