Learn how to extract property listings from Homes.com using ScrapeGraphAI’s SmartScraper. This example demonstrates how to gather detailed property information, pricing, and agent details.

Try it yourself in our interactive notebooks:

The Goal

We’ll extract the following property information:

FieldDescription
PriceProperty price in USD
BedroomsNumber of bedrooms
BathroomsNumber of bathrooms
Square FeetTotal square footage
AddressProperty address
CityProperty city
StateProperty state
ZIP CodeLocation ZIP code
TagsProperty features
AgentListing agent name
AgencyListing agency

Code Example

from pydantic import BaseModel, Field
from typing import List, Optional
from scrapegraph_py import Client

# Schema for a single house listing
class HouseSchema(BaseModel):
    price: int = Field(description="Price of the house in USD")
    bedrooms: int = Field(description="Number of bedrooms")
    bathrooms: int = Field(description="Number of bathrooms")
    square_feet: int = Field(description="Total square footage of the house")
    address: str = Field(description="Address of the house")
    city: str = Field(description="City where the house is located")
    state: str = Field(description="State where the house is located")
    zip_code: str = Field(description="ZIP code of the house location")
    tags: List[str] = Field(description="Tags like 'New construction' or 'Large garage'")
    agent_name: str = Field(description="Name of the listing agent")
    agency: str = Field(description="Agency listing the house")

# Schema containing a list of house listings
class HouseListingsSchema(BaseModel):
    houses: List[HouseSchema] = Field(description="List of house listings on Homes.com or similar platforms")

client = Client(api_key="your-api-key")

response = client.smartscraper(
    website_url="https://www.homes.com/san-francisco-ca/?bb=nzpwspy0mS749snkvsb",
    user_prompt="Extract property listings information",
    output_schema=HouseListingsSchema
)

Example Output

{
    "houses": [
        {
            "price": 750000,
            "bedrooms": 4,
            "bathrooms": 3,
            "square_feet": 2500,
            "address": "123 Main Street",
            "city": "San Francisco",
            "state": "CA",
            "zip_code": "94105",
            "tags": ["New Construction", "Smart Home", "Mountain View"],
            "agent_name": "Jane Smith",
            "agency": "Bay Area Realty"
        },
        {
            "price": 525000,
            "bedrooms": 3,
            "bathrooms": 2,
            "square_feet": 1800,
            "address": "456 Oak Avenue",
            "city": "San Francisco",
            "state": "CA",
            "zip_code": "94110",
            "tags": ["Recently Renovated", "Garage", "Garden"],
            "agent_name": "John Davis",
            "agency": "Golden Gate Properties"
        }
    ]
}

Have a suggestion for a new example? Contact us with your use case or contribute directly on GitHub.