4.0 UK Estate Agent Scraper (Trojan A)
Specification, workflow, and technical reference for the UK Estate Agent Scraper — the Companies House B2B estate agency lead ingestion pipeline.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
Autonomous overnight intelligence engine that builds a proprietary, continuously-updated B2B prospect database of every registered UK estate and lettings agency.
The Postman on Steroids
Imagine a postman who collects property cards from every agent's website in the country, every single day. The scraping pipeline is that postman on steroids: it has a route (the list of agency domains), a bag (a content-hash database that detects what changed since yesterday), and a sorting office (a queue of background workers that re-parse, re-geocode, and re-list anything new). When an agent changes a price at 2am, our system knows by 6am.
Pipeline Architecture
The pipeline is a 3-stage sequential process coordinated by nightly-gtm-coordinator.py:
-
1Companies House Scraper —
companies-house-scrape.pyQueries the Companies House API for all active companies with SIC 68310. Paginates at 20 results/page, resuming from the last offset stored in
daemon-state.json. Applies a financial stability grading algorithm (A/B1/B2/C/D) based on accounts overdue status, accounts type, and trading activity. Writes raw results toestate_agents_companies_house.csv. -
2Relational Ingestion Pipeline —
gtm-leads-ingestion-pipeline.pyReads the CSV and relationalises each agency into Supabase: creates a
tbl_personsrecord for each director (status:lead), upserts the organisation intotbl_organisations_data, geocodes the registered address (lat/lng), parses the UK postcode for region, and creates waitlist-status pre-onboard records. Deduplicates by Companies House number — safe to run repeatedly. -
3Geocoded Leaflet Map —
gtm_prospect_profile.htmlReads geocoded lat/lng from the database and regenerates an interactive Leaflet.js map with colour-coded pins by financial grade, filtering controls, and a prospect profile panel. Served at http://100.120.31.7/gtm_prospect_profile.html.
Cron Schedule
Two cron jobs manage the scraping lifecycle. Both run on the Hermes scheduler and deliver reports to Telegram.
| Job Name | Schedule | What It Does | Last Status |
|---|---|---|---|
raia-nightly-gtm-ingest |
0 2 * * *02:00 UTC nightly |
Runs all 3 stages: scrape → ingest → map regeneration. Advances ~20 pages (~385 new agencies) per run. | error Jun 2 (check logs) |
raia-companies-house-leads-refresh |
0 5 * * 0Sunday 05:00 UTC |
Weekly deep refresh — re-scrapes all known companies to update financial grades and detect status changes (dissolutions, new filings). | ok May 31 |
Database Schema
All scraped data lives in the db_raia Supabase project. Three tables are involved:
tbl_companies_house_leads
Raw Companies House registry data for every estate agency scraped. The canonical source of truth for B2B prospect intelligence.
tbl_organisations_data
Relationalised pre-onboard record. Each scraped agency becomes a status: waitlist organisation here.
tbl_waitlist (app DB)
When someone submits the waitlist form, the action matches their company field against tbl_organisations.name.
Repository Code
The live codebase implementation for this textbook logic sits within the following repository folder:
File Layout
03_technology/09_pipelines/programs/
├── nightly-gtm-coordinator.py # Master orchestrator (cron entrypoint)
├── companies-house-scrape.py # Stage 1: CH API → CSV
├── gtm-leads-ingestion-pipeline.py # Stage 2: CSV → Supabase relational
├── gtm-social-enrichment.py # Optional: LinkedIn/web enrichment
├── daemon-state.json # Scraper resume state (last_page, total)
├── estate_agents_companies_house.csv # Latest batch raw output
└── nightly-gtm.log # Rolling log of all nightly runs
Checking the Log
tail -60 /root/projects/raia/03_technology/09_pipelines/programs/nightly-gtm.log
Waitlist Matching
The waitlist form today matches only via company name (ILIKE %term% against tbl_organisations). It does NOT yet cross-reference tbl_companies_house_leads directly — meaning we may miss agencies that registered in Companies House but haven't been promoted to tbl_organisations yet.