Files

60 lines
2.1 KiB
Python

import requests, json, re
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/124 Safari/537.36",
"Accept": "application/json, text/plain, */*",
"Accept-Language": "en-US,en;q=0.9",
"Referer": "https://www.redfin.com/",
}
# Redfin city region IDs for Florida coastal cities
FL_CITY_IDS = {
"Vero Beach": 19073,
"Sebastian": 16461,
"Stuart": 16992,
"Jensen Beach": 9058,
"Fort Pierce": 7528,
"Port St. Lucie": 15348,
"Melbourne": 12007,
"Cocoa Beach": 5401,
"Cocoa": 5400,
"Titusville": 18427,
"Daytona Beach": 5866,
"Ormond Beach": 14428,
"New Smyrna Beach": 13473,
"Palm Coast": 14706,
"St. Augustine": 16629,
"Jacksonville": 9009,
"Jacksonville Beach": 9004,
"Atlantic Beach": 2075,
"Neptune Beach": 13437,
"Fernandina Beach": 7082,
}
print("=== Testing Redfin with Florida region IDs ===\n")
total_found = 0
for city, region_id in list(FL_CITY_IDS.items())[:5]:
try:
url = (f"https://www.redfin.com/stingray/api/gis?"
f"al=1&market=florida&region_id={region_id}&region_type=6"
f"&status=9&uipt=1,2,3,4&max_price=230000&num_homes=10&start=0&v=8")
r = requests.get(url, headers=headers, timeout=15)
data = json.loads(r.text.replace("{}&&", ""))
homes = data.get("payload", {}).get("homes", [])
print(f"{city} (id={region_id}): {len(homes)} homes found")
for h in homes[:2]:
price = h.get("price", {}).get("value", 0)
addr = h.get("streetLine", {}).get("value", "?")
hcity = h.get("city", "?")
state = h.get("state", "?")
beds = h.get("beds", "?")
sqft = h.get("sqFt", {}).get("value", "?")
status = h.get("mlsStatus", "?")
print(f" ${price:,} | {addr}, {hcity}, {state} | {beds}bd | {sqft}sqft | {status}")
total_found += len(homes)
except Exception as e:
print(f"{city}: ERROR {e}")
print(f"\nTotal found in 5 cities: {total_found}")