Prompt

How do I scrape real estate listings and normalize the fields?

Technology / API Platforms2 observationsLast seen Oct 24, 2026

Latest observation

Oct 24, 2026OpenAI APIWeb search: off

To scrape real estate listings and normalize the fields, think of it as a 3-step pipeline:

  1. Collect listings
  2. Extract data from each listing page
  3. Normalize everything into a consistent schema

1) Define a target schema first

Before scraping, decide the fields you want in every record. For example:

{
  "listing_id": "",
  "source": "",
  "url": "",
  "title": "",
  "price": null,
  "currency": "USD",
  "property_type": "",
  "status": "",
  "beds": null,
  "baths": null,
  "sqft": null,
  "lot_sqft": null,
  "address": "",
  "city": "",
  "state": "",
  "zip": "",
  "lat": null,
  "lng": null,
  "description": "",
  "images": [],
  "agent_name": "",
  "agent_phone": "",
  "posted_at": null,
  "scraped_at": null
}

This gives you a common output even if different sites label things differently.


2) Scrape listing pages ethically and reliably

Best practices

  • Check the site’s Terms of Service and robots.txt
  • Use rate limiting and polite delays
  • Prefer official APIs or data feeds when available
  • Avoid login walls or anti-bot bypasses unless you’re authorized

Common tooling

  • Requests + BeautifulSoup for static pages
  • Scrapy for large crawls
  • Playwright or Selenium for JavaScript-rendered pages
  • Pandas for cleaning and normalization

3) Extract fields from messy HTML

Real estate sites often use inconsistent labels:

  • “Beds”, “Bedrooms”, “BR”
  • “Baths”, “Bathrooms”, “BA”
  • “Sq Ft”, “Square Feet”, “Interior area”

You’ll want mapping logic.

Example extraction logic

import re

def parse_price(text):
    if not text:
        return None
    text = text.replace(',', '')
    m = re.search(r'(\$|€|£)?\s*([\d]+(?:\.\d+)?)', text)
    return float(m.group(2)) if m else None

def parse_int(text):
    if not text:
        return None
    m = re.search(r'[\d,]+', text)
    return int(m.group(0).replace(',', '')) if m else None

def normalize_beds(text):
    if not text:
        return None
    text = text.lower().strip()
    if 'studio' in text:
        return 0
    m = re.search(r'(\d+(\.\d+)?)', text)
    return float(m.group(1)) if m else None

4) Normalize units and formats

Different sources may use:

  • Sq ft vs m²
  • Price strings with currency symbols
  • Dates in different formats
  • Different state/country conventions for addresses

Unit normalization examples

  • Convert m² to sqft using 1 m² = 10.7639 sqft
  • Standardize date fields to ISO 8601 (YYYY-MM-DD)
  • Split address into structured components if possible
def sqm_to_sqft(sqm):
    return round(sqm * 10.7639) if sqm is not None else None

5) Standardize addresses

Use a geocoder or address parser if you need structured location fields.

Approach

  • Keep original address string
  • Try to parse:
    • street
    • city
    • state/province
    • postal code
  • Geocode to get lat/lng

Useful libraries/services:

  • libpostal for parsing addresses
  • Google Geocoding API
  • Nominatim / OpenStreetMap
  • Here / Mapbox geocoding APIs

6) Handle inconsistent listing pages

Often, the same site has:

  • detail pages with all fields
  • search pages with summary fields only
  • hidden JSON embedded in HTML

Look for structured data

Many listing pages include:

  • JSON-LD (application/ld+json)
  • OpenGraph metadata
  • embedded JavaScript state objects

Example:

import json
from bs4 import BeautifulSoup

def extract_json_ld(html):
    soup = BeautifulSoup(html, "html.parser")
    scripts = soup.find_all("script", type="application/ld+json")
    data = []
    for s in scripts:
        try:
            data.append(json.loads(s.string))
        except Exception:
            pass
    return data

Structured data is often more reliable than scraping visible text.


7) Create a normalization layer

A good pattern is:

Raw extract

Keep exactly what the site gave you:

raw = {
    "price_text": "$1,250,000",
    "beds_text": "3 beds",
    "area_text": "1,842 sqft"
}

Normalized record

Convert to your canonical schema:

normalized = {
    "price": 1250000,
    "beds": 3,
    "sqft": 1842
}

This lets you reprocess later if parsing rules improve.


8) Deduplicate listings

Real estate listings can appear multiple times across:

  • search pages
  • syndication partners
  • mirrored sites

Use:

  • source listing ID if available
  • canonical URL
  • fuzzy matching on address + price + beds + sqft

A common dedupe key:

dedupe_key = f"{address}|{price}|{beds}|{baths}|{sqft}"

9) Suggested architecture

A practical scraper pipeline:

  1. Crawler discovers listing URLs
  2. Fetcher downloads page HTML
  3. Parser extracts raw fields
  4. Normalizer cleans and standardizes fields
  5. Storage writes to database/CSV/Parquet
  6. QA checks missing values and anomalies

10) Example end-to-end sketch

import requests
from bs4 import BeautifulSoup

def scrape_listing(url):
    html = requests.get(url, timeout=20, headers={
        "User-Agent": "Mozilla/5.0"
    }).text

    soup = BeautifulSoup(html, "html.parser")

    title = soup.select_one("h1")
    price = soup.select_one(".price")

    record = {
        "url": url,
        "title": title.get_text(strip=True) if title else None,
        "price": parse_price(price.get_text(" ", strip=True) if price else None),
        "scraped_at": "2026-10-24"
    }
    return record

11) Quality checks you should add

  • Missing value rate per field
  • Outlier detection for price/sqft/beds
  • Invalid addresses
  • Currency mismatches
  • Broken image URLs
  • Duplicate listing IDs

12) If you’re scraping at scale

Use:

  • Scrapy
  • Redis queue
  • async requests
  • rotating proxies only if permitted
  • centralized logging
  • retry/backoff handling
  • stored raw HTML snapshots for debugging

13) Practical normalization rules

Examples:

  • beds: convert "3+" to 3 or 3.0
  • baths: keep half baths as 2.5
  • sqft: parse commas and remove text
  • price: remove $, ,, and "from"/"starting at"
  • status: map variants to active, pending, sold, off_market
  • property_type: map condo, apartment, townhouse, single_family

If you want, I can give you:

  1. a Python Scrapy project template,
  2. a BeautifulSoup parser for a sample listing page, or
  3. a field-normalization function set for beds/baths/price/address.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.