RentProfile R2R Photo Scraper
Right to Rent checks confirm a tenant is legally allowed to live in the UK. The system did not automatically save the tenant photo from the check into our platform. This page explains the automated pi
Right to Rent checks confirm a tenant is legally allowed to live in the UK. The system did not automatically save the tenant photo from the check into our platform. This page explains the automated pi
RentProfile R2R Photo Scraper
Right to Rent checks confirm a tenant is legally allowed to live in the UK — this automated pipeline logs into RentProfile, scrapes certificate PDFs, extracts the face photo, and backfills the tenant record in Supabase.
Right to Rent checks confirm a tenant is legally allowed to live in the UK. The system did not automatically save the tenant photo from the check into our platform. This page explains the automated pipeline that fixes that — downloading the certificate, extracting the face photo, and storing it against the tenant record.
RentProfile R2R Photo Scraper
Automated Playwright pipeline — logs into any RentProfile agent account, scrapes all Right to Rent certificate PDFs, extracts the embedded face photo, and backfills tbl_persons.avatar_url in Supabase. Zero manual downloads. Reusable across all estate agent clients.
TL;DR. RentProfile embeds the tenant's liveness face photo inside the Right to Rent certificate PDF. This tool logs into any RentProfile agent dashboard with saved credentials, visits the R2R Reporting tab, downloads every certificate PDF, extracts image index [1] (the face) using PyMuPDF, uploads to gs://rcf_public/avatar/<person_id>.jpg, and writes the public URL to tbl_persons.avatar_url. Confirmed working on RAIA (Real estate Artificial Intelligence Agent) portfolio June 2026 (29 written, 0 errors, 136s).
03_technology/09_pipelines/programs/execSync (NOT inline -c flag). Same directory.--report flag — lists all 44 missing persons with name, role, tenancy_ref, email, person_id. Share with human reviewer before running --write.Chapter 1 Why This Tool Exists
- RentProfile makes photo upload optional — conversion rate optimisation
request_idwas never stored in AppSheet, MySQL, or Supabase during migration- API lookup requires
request_id— no list/search endpoint exists - All 44 active tenants show silhouette placeholder in portal UI
- R2R PDFs exist on RentProfile servers but were never pulled back to RAIA
- R2R certificate PDFs contain the face JPEG at image index [1]
- R2R record
idis visible in the URL — norequest_idneeded - Playwright can log in, scrape the full R2R list, and download all PDFs
- PyMuPDF extracts the face photo in <1 second per PDF
- GCS upload + Supabase write completes the backfill end-to-end
Why It's a Reusable Tool — Not a One-Off Script
Every estate agent we onboard who uses RentProfile will have the same gap: R2R PDFs on RentProfile servers, face photos never synced to RAIA. This tool becomes the standard onboarding backfill step for all RentProfile agencies. The only per-client variables are the agent login credentials and the Supabase database target.
The API Red-Team: Why We Built the Scraper
Before writing a single line of Playwright code, we ran a structured red-team of the RentProfile API — following what is now the standard Three-Method Extraction Protocol (see § 4.2 ETL Method). Here is exactly what we found:
- One usable endpoint:
/v1/api/status/request - Requires
request_idper call — no list or search endpoint request_idwas never captured during AppSheet → Supabase migration- Result: API useful only for targeted lookups, not bulk extraction
- Conclusion: API alone cannot complete the backfill
- No
/.well-known/mcp.jsonendpoint detected - No SSE or WebSocket event stream available
- No tool registry exposed
- Expected — RentProfile is a closed legacy SaaS
- Conclusion: MCP not available; skip
- Authenticated login succeeds with agency credentials
/agent/r2r-reportingpaginates all R2R records without needingrequest_id- Individual certificate PDFs downloadable via record-level URL
- PDFs contain embedded face JPEG at image index [1] (PyMuPDF confirmed)
- Conclusion: Browser scrape is the primary extraction method
The API and browser scraper now run as complementary tools. The scraper handles bulk list extraction and PDF retrieval. The API handles targeted status lookups when a request_id is available (e.g. from an invite email or agent dashboard URL). Both outputs are cross-referenced to validate completeness — if the API returns a record not found in the scrape list, it surfaces as a data quality flag for investigation.
This pattern — red-team the API, confirm MCP absence, build the browser supplement, cross-reference both — is now the universal RAIA™ (Real estate Artificial Intelligence Agent) standard for all legacy PropTech integrations. The RentProfile tool is the canonical reference implementation. See § 4.1 Legacy Data Sources & Systems for how this applies across the full PropTech ecosystem.
RAIA (Real estate Artificial Intelligence Agent) processes tenant face photos as a data controller under UK GDPR Article 6(1)(b) (contractual necessity — property management agreement with landlord) and Article 6(1)(c) (legal obligation — Right to Rent verification under Immigration Act 2014). RAIA's lawful basis is independent of RentProfile's original processing — each controller must establish their own basis. Face photos are minimal biometric data retained solely for identity verification at viewings and video calls, proportionate to the legitimate purpose.
Active and renewing tenants + guarantors only. Never leads, enquiries, completed tenancies, or contacts without a tenancy link. See Pitfall P-01.
Once Blinc (mandatory biometric selfie) is live, this gap never recurs for new tenancies. This tool handles the historic migration debt only.
Chapter 2 How It Works
Pipeline Architecture Map
Security Model — Why It Cannot Mutate Data
RentProfile has no read-only sub-user or RBAC. One login = full agency access. The protection lives entirely in our scraper code — three independent layers prevent any write operation from occurring on the RentProfile platform.
Data Flow — What Moves Where
Raw ID documents (full passport page, referencing PDF) → gs://raia-gb-private/ — private bucket, never public. Only the cropped face portrait → gs://rcf_public/avatar/. These must never be mixed.
Chapter 3 Running the Tool
Prerequisites
- RentProfile agent login email + password in
.env.local SUPABASE_SERVICE_ROLE_KEYin same file- GCS service account key at
/root/storage-admin-key.json
playwright-extra—npm install playwright-extrapuppeteer-extra-plugin-stealth—npm install puppeteer-extra-plugin-stealthplaywrightchromium —npx playwright install chromiumpymupdf(fitz) —pip install pymupdf@google-cloud/storagenode package@supabase/supabase-js
tbl_persons.avatar_url— writabletbl_migration_contacts— readable (name/email join)tbl_tenancies_persons— readable (scope filter)
Two-Phase Production Methodology
The scraper must always be run in two phases in production. Never run --write without first completing a dry-run and saving the plan.
- Phase A — Dry-run (plan generation): Run without
--write. The scraper logs into RentProfile, paginates all 950 list pages, matches each R2R record to a Supabaseperson_id, and saves the complete mapping to/tmp/r2r-dryrun-plan.json. This JSON contains all 29r2r_id → person_idmappings. Nothing is downloaded or written. Review the output before proceeding.nodescrape-rentprofile-r2r-avatars.cjs# dry-run is the default — saves /tmp/r2r-dryrun-plan.json - Phase B — Write (from-plan): Run with
--write --from-plan=/tmp/r2r-dryrun-plan.json. The scraper skips the entire 950-page list re-scrape and jumps directly to downloading and processing the 29 matched persons. This takes approximately 136 seconds instead of ~190s for the full re-scrape path.nodescrape-rentprofile-r2r-avatars.cjs--write--from-plan=/tmp/r2r-dryrun-plan.json# Skips 950-page list re-scrape entirely# ~136s for 29 persons · 0 errors in production June 2026
Why this matters: Without --from-plan, every write run burns ~56 seconds and ~950 list-page requests before downloading a single certificate. This risks triggering RentProfile rate limits before the actual work begins. The plan file is cheap to regenerate — always use it.
Step-by-Step Execution
-
1Generate the candidate list (CSV report)
Run with
--reportto produceavatar-backfill-report.csv— lists all persons in scope with name, role, tenancy_ref, email, person_id. Review before proceeding.nodescrape-rentprofile-r2r-avatars.cjs--report -
2Dry run — see what would be downloaded (Phase A)
Default mode. Logs into RentProfile, scrapes the R2R list, matches names to Supabase persons, prints what it would do, and saves
/tmp/r2r-dryrun-plan.json. Nothing is written.nodescrape-rentprofile-r2r-avatars.cjs# Dry run is the default — no --write flag# Output: list of matched PDFs + person_ids + estimated face size# Saves: /tmp/r2r-dryrun-plan.json (all r2r_id→person_id mappings) -
3Live run — execute the backfill (Phase B)
Runs the full pipeline. Use
--from-planto skip the 950-page list re-scrape. Logs every step. Createsrun-report.jsonon completion.nodescrape-rentprofile-r2r-avatars.cjs--write--from-plan=/tmp/r2r-dryrun-plan.json# Optional flags:--limit=10# process first N persons only--person=UUID# process a single person_id--delay=5000# ms delay between PDF downloads (default 5000)--from-plan=PATH# skip list re-scrape, load plan from dry-run JSON -
4Review the audit log
Check
run-report.jsonfor: processed count, skipped (silhouettes), failed (no match / PDF error), GCS URLs written, Supabase rows updated.catrun-report.json| jq'.summary' -
5Verify in portal
Spot-check 3–5 persons in the RAIA (Real estate Artificial Intelligence Agent) portal — avatar should now show their face photo. For any failures, check
run-report.jsonerror field and re-run with--person=UUID.
Chapter 4 New Estate Agent Onboarding
When signing on a new UK estate agency that uses RentProfile, run this tool as part of the standard data migration playbook. It is a one-time backfill per client — after Blinc goes live for new tenancies, the gap never recurs.
Onboarding Checklist — Per Client
- Ask client: are you on RentProfile? → If yes, this tool applies
- Collect agent login credentials → store in
.env.localper pattern in this guide - Confirm Supabase project ID and service role key for the client DB
- Confirm GCS bucket name — default
rcf_public/avatar/— verify public access is on - Run
--reportfirst — share CSV with client contact for sign-off before photos are pulled - Dry run — confirm all person_id matches are correct (no name collisions) — saves plan JSON
- Live run with
--write --from-plan=/tmp/r2r-dryrun-plan.json - Review
run-report.json— all processed count matches expected scope - Spot-check 5 photos in portal — confirm quality (face visible, not silhouette)
- Ask client: rotate RP password after run, or keep same for periodic re-sync cron
- Do NOT run against completed/past tenants — only active, renewing, moving_out
Chapter 5 Configuration Reference
Environment Variables
| Variable | Location | Required | Notes |
|---|---|---|---|
RENTPROFILE_AGENT_EMAIL | portal/.env.local | Required | Agent dashboard login email — never commit |
RENTPROFILE_AGENT_PASSWORD | portal/.env.local | Required | Agent dashboard password — never commit |
RENTPROFILE_API_KEY | portal/.env.local | Optional | Not used by scraper — used by Status/Result API only |
NEXT_PUBLIC_SUPABASE_URL | portal/.env.local | Required | Target Supabase project URL |
SUPABASE_SERVICE_ROLE_KEY | portal/.env.local | Required | Service role key — write access to tbl_persons |
| GCS service account | /root/storage-admin-key.json | Required | GCS write access to rcf_public bucket |
CLI Flags
| Flag | Default | Description |
|---|---|---|
--report | off | Generate avatar-backfill-report.csv — candidate list only, no login |
--dry-run | on | Default mode — login, scrape, extract, but do NOT write to GCS or Supabase. Saves plan to /tmp/r2r-dryrun-plan.json |
--write | off | Execute the full pipeline — GCS upload + Supabase avatar_url write |
--from-plan=PATH | none | Skip the 950-page R2R list re-scrape and load r2r_id → person_id mappings from a previously saved dry-run plan JSON. Always use with --write in production. |
--limit=N | all | Process first N matched persons only — useful for spot-testing |
--person=UUID | all | Process a single person_id — re-run failed individuals |
--delay=MS | 5000 | Milliseconds between PDF downloads — never set below 3000 on production (2000 triggered rate limiting) |
--headless=false | true | Show browser window — useful for debugging login failures |
RentProfile URL Allowlist (hardcoded)
constALLOWED_URLS= ['https://www.rentprofile.co/agent/login','https://www.rentprofile.co/agent/dashboard','https://www.rentprofile.co/agent/reporting/right_to_rent','https://www.rentprofile.co/agent/view_r2r_in_detail',// PDF download endpoint (matches by prefix)'https://www.rentprofile.co/agent/download_r2r_document',// RentProfile S3 media — PDFs and cert assets (some served as .jpg)'https://rentprofile-media.s3.eu-west-1.amazonaws.com/',]// Any navigation outside this list throws an Error and aborts the run
File Inventory
| File | Path | Purpose |
|---|---|---|
scrape-rentprofile-r2r-avatars.cjs |
03_technology/09_pipelines/programs/ |
Main scraper — Playwright + PDF download + face extract + GCS + Supabase |
extract_pdf_image.py |
03_technology/09_pipelines/programs/ |
PyMuPDF helper — extracts face JPEG at image index [1] from R2R certificate PDF |
backfill-avatars-from-r2r-pdf.cjs |
03_technology/09_pipelines/programs/ |
Manual variant — processes PDFs Mi has already downloaded to a local folder |
backfill-avatars-from-rentprofile.cjs |
03_technology/09_pipelines/programs/ |
API variant — uses Status API with request_id (blocked until request_ids recovered) |
avatar-backfill-report.csv |
03_technology/09_pipelines/programs/ |
Generated by --report — candidate list for human review |
run-report.json |
03_technology/09_pipelines/programs/ |
Generated after each run — processed / skipped / failed / GCS URLs |
Pitfalls
There are ~52,220 NULL-avatar rows in tbl_persons. The vast majority are leads and enquiries for whom we hold no ID documents. Only query: tbl_tenancies_persons.role IN ('lead_tenant','co_tenant','guarantor') joined to active/renewing tenancies. Running a broader query wastes API calls and may attempt to pull photos for non-tenants.
The R2R certificate PDF contains 3 images on page 0: [0] = RentProfile logo (PNG, ~134 bytes), [1] = face JPEG (~372KB), [2] = watermark badge. Always extract index [1]. If len(imgs) < 2, the PDF has no face photo — skip and log.
execSync python3 -c for PyMuPDF — use a .py fileNewlines in the inline script string become literal \n sequences and throw SyntaxError. Always write the extraction logic to extract_pdf_image.py and call it as: execSync(`python3 /path/to/extract_pdf_image.py ${JSON.stringify(pdfPath)} ${JSON.stringify(tmpDir)}`)
For clients with 100+ R2R records, the session cookie may expire during the run. The scraper should detect a redirect back to /agent/login and re-authenticate automatically. Check for this in large-portfolio runs.
A silhouette image may still be extracted at index [1]. Always filter: skip if JPEG is <5KB (silhouette is typically 2–3KB) AND skip if the extracted bytes match known silhouette hash. Log skipped items as SILHOUETTE_SKIP not ERROR.
RentProfile S3 stores PDFs at .jpg URLs. Always check magic bytes (FF D8 = JPEG, 25504446 = %PDF) — do NOT trust the URL extension. Upload the wrong file type and the browser silently shows nothing (the img tag fires onError and the avatar disappears).
RentProfile may store tenant as "John Smith" while Supabase has "Jonathan Smith". Use: exact match first → fuzzy match (Levenshtein distance ≤2) → email match fallback. Any match below 90% confidence should be logged as MANUAL_REVIEW and skipped in --write mode.
require('dotenv').config()Manually parse the .env.local file and inject into process.env. Path from 09_pipelines/programs/ to portal/.env.local is ../../11_frontend/portal/.env.local (2 levels up, not 3). Verify with console.log(process.env.NEXT_PUBLIC_SUPABASE_URL) after loading.
Hardcode skip list by person_id: 8f7f0bbe (Alice Sovereign Agent — test), c982ae93 (Brunei High Commission — diplomatic), e307eabc (Earthmall Ltd — company), 08566531 (Reading FC — org). These will never have face photos.
domcontentloaded not networkidle — third-party analytics cause false timeoutsRentProfile loads third-party analytics (Stripe, Pirsch, TrustPilot) that never fully settle their network connections. Using waitUntil: 'networkidle' causes false 30-second timeouts on every page in the scraper. Use waitUntil: 'domcontentloaded' throughout — the DOM is ready and interactive well before the analytics settle.
Promise.all login pattern — SPA does not fire navigation after form submitRentProfile is a SPA and does not fire a full navigation event after the login form is submitted. The correct pattern is:
awaitPromise.all([page.waitForNavigation({waitUntil:'domcontentloaded'}),page.click(submitSelector)]);// NEVER: await page.click(submitSelector); await page.waitForNavigation()// Awaiting navigation AFTER click will miss the navigation event entirely.
Headless Chromium without the playwright-extra stealth plugin is detected and blocked by RentProfile's CDN. The block is silent — pages may load but the login form may behave unexpectedly or sessions may fail to persist.
// Install:npminstall playwright-extra puppeteer-extra-plugin-stealth// Initialise BEFORE any page.goto call:const{chromium}=require('playwright-extra');conststealth=require('puppeteer-extra-plugin-stealth')();chromium.use(stealth);
--from-plan is critical for production — without it, 950 pages are re-scrapedWithout --from-plan, every --write run re-scrapes all 950 list pages before any certificate downloads begin. This burns approximately 56 seconds of requests and risks triggering RentProfile rate limits before a single certificate is downloaded. Always run the dry-run first, save the plan JSON, then pass --write --from-plan=<path> for the write phase.
A 2-second delay between certificate detail page requests triggered rate limiting in the June 2026 production run. The default DELAY_MS is now 5000ms. Never pass --delay below 3000 on production. If you see 302 redirects to the S3 error page (see P-15), wait 10+ minutes and increase the delay before retrying.
RentProfile throttles after the first detail page visit in rapid succession. The scraper retries up to 3 times with 6s, then 12s backoff delays between retries. Do not disable or shorten these retry intervals — they are the difference between a successful run and a permanently rate-limited session.
The visible symptom of RentProfile rate limiting is a 302 redirect to rentprofile-media.s3.eu-west-1.amazonaws.com/error.html. If you see this URL appear in debug screenshots or Playwright navigation logs, stop the run immediately. Wait 10+ minutes before retrying. Continuing will not help — the rate limit applies to the session and IP.
The R2R reporting list grows as new Right to Rent checks are added across all tenancies. The dry-run page count will increase over time. The early-stop logic (stops paginating once all target person names have been found) prevents scraping unnecessary pages — but dry-run will still take longer as the portfolio grows. This is expected behaviour, not a bug.
.jpg URL extension — 14 of 29 certs were PDFsIn the June 2026 production run, 14 of 29 R2R certificates were PDFs served from RentProfile S3 at URLs ending in .jpg. Uploading a PDF buffer as image/jpeg to GCS results in a broken avatar — the browser fires onError for the <img> tag and silently hides it.
Always check Buffer magic bytes after download, before deciding how to process:
FF D8at bytes [0–1] → genuine JPEG — use directly as avatar25 50 44 46(%PDF) at bytes [0–3] → PDF — must extract via PyMuPDF first, then upload the extracted face JPEG
Never trust the .jpg URL extension. Always trust the magic bytes.
Vibe Check — SOP Test Checklist
Run before every live execution. All green before --write.
Pre-Run Gates
-
RENTPROFILE_AGENT_EMAILis set in.env.local -
RENTPROFILE_AGENT_PASSWORDis set in.env.local -
SUPABASE_SERVICE_ROLE_KEYis set -
/root/storage-admin-key.jsonexists and is valid -
playwright-extrainstalled (npm install playwright-extra) -
puppeteer-extra-plugin-stealthinstalled (npm install puppeteer-extra-plugin-stealth) -
playwright+ chromium installed (npx playwright install chromium) -
pymupdfinstalled (pip install pymupdf) -
--reportCSV reviewed and approved - Dry run completed — matches look correct —
/tmp/r2r-dryrun-plan.jsonsaved - Do NOT run if any active tenancy dispute is ongoing for a matched person
Post-Run Verification
-
run-report.json— processed count matches expected scope - Zero
ERRORentries (or all errors explained) - GCS URLs are HTTPS (not
gs://protocol) - Spot-check 5 persons in RAIA (Real estate Artificial Intelligence Agent) portal — faces visible
- No silhouettes written (check
run-report.jsonsilhouette_skip count) - Verify GCS content-type is
image/jpeg— notapplication/pdf(run:gsutil stat gs://rcf_public/avatar/<person_id>.jpgand checkContent-Type) - Any
MANUAL_REVIEWitems — resolve manually - Consider rotating RentProfile password after run
- Commit
run-report.jsonto repo for audit trail
This tool is production-ready for any UK estate agent using RentProfile. The only client-specific configuration is: credentials in .env.local, Supabase project URL, and GCS bucket name. All guard rails, dry-run defaults, and audit logging are built in. Production result June 2026: 29 written, 0 errors, 136s.
Author: RAIA (Real estate Artificial Intelligence Agent) OS — EstateAigents.com · Version: 1.1 · Last updated: June 2026
Architecture Details
Hermes Agent architecture follows a profile-based isolation model where each profile has its own configuration, skills, tools, cron jobs, and memory stores. The two-gate system enforces identity verification at the network level, then profile-level authorisation within the application. Delegation routing uses a model-selection strategy (cost_optimized, precision, or speed) to match tasks to the optimal LLM provider.
- Core Component: Hermes Agent orchestration and profile management engine
- Data Flow: User Request → Profile Selection → Gate Verification → Tool Execution → LLM Inference → Response
- Integration Points: LLM providers (OpenRouter, OpenAI, Anthropic), tool registry, memory stores, delegation bus
Configuration Reference
Key configuration parameters for this system:
| Parameter | Type | Default | Description |
|---|---|---|---|
| default_profile | string | default | Active profile for tool execution |
| delegation_model | string | cost_optimized | Model routing strategy for delegation |
| max_concurrent_children | integer | 3 | Max parallel subagent tasks |
Figure 2: Hermes Agent architecture — component interaction and data flow.
Troubleshooting
| Issue | Cause | Resolution |
|---|---|---|
| Profile not found | Profile name misconfigured or missing directory | Verify profile exists in ~/.hermes/profiles/ |
| Gate guard blocks access | Hostname not in allowed list | Add hostname to gate guard whitelist |
This component is part of the RAIA (Real estate Artificial Intelligence Agent) platform mono-repo. Implementation details, API contracts, and integration tests are available in the repository.