The challenge
Santa Barbara home prices run from under half a million to almost ten million dollars, and listing sites show them one house at a time. There is no clean table of what sold, what it was like and where it was.
I wanted to build that table myself so I could ask which features actually move price: size, lot, age, ZIP code, or the things agents highlight in the description.
The approach
A Requests and BeautifulSoup scraper walks Trulia's sold-homes search for Santa Barbara, opens every listing and pulls price, beds, baths, size, lot and year built. It waits a random 20 to 30 seconds between requests, rotates user agents and tries a backup selector whenever a field is missing. Everything lands in SQLite, so the analysis never has to touch the site again.
The most useful trick is in cleaning. Descriptions are free text, so the cleaner scans each one for phrases like "ocean view", "pool" and "garage" and turns them into 0/1 features. The notebooks then test price differences across ZIP codes with a one-way ANOVA built by hand, one-hot encode the nine ZIPs, check feature overlap with PCA and mutual information, and set up OLS and CatBoost models on log-transformed price.
- Polite, resilient scraperRandomized pacing, rotating user agents and a backup extractor for each size field.
- SQLite hand-offRaw and cleaned tables share one SQLite file, so each step reruns on its own.
- Text to featuresSix 0/1 flags parsed from listing descriptions, from garage to ocean view to Isla Vista.
- Statistical checksA hand-built one-way ANOVA of price by ZIP code, plus PCA, K-means and mutual information.
Scrape to model
- 01ScrapeTrulia sold listings, paced
- 02StoreRaw rows into SQLite
- 03CleanOutlier filters and text flags
- 04ModelOne-hot ZIPs, log price, OLS and CatBoost




