Use this file to discover all available pages before exploring further.
Learn how to extract property listings from Homes.com using ScrapeGraphAIโs Extract service. This example demonstrates how to gather detailed property information, pricing, and agent details.
from pydantic import BaseModel, Fieldfrom typing import List, Optionalfrom scrapegraph_py import ScrapeGraphAI# Schema for a single house listingclass 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 listingsclass HouseListingsSchema(BaseModel): houses: List[HouseSchema] = Field(description="List of house listings on Homes.com or similar platforms")sgai = ScrapeGraphAI() # reads SGAI_API_KEY from envres = sgai.extract( "Extract property listings information", url="https://www.homes.com/san-francisco-ca/?bb=nzpwspy0mS749snkvsb", schema=HouseListingsSchema.model_json_schema(),)if res.status == "success": print(res.data.json_data)