"""Inspect actual content of /searchresult?state=FL.""" from __future__ import annotations import io, sys, time sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace") from playwright.sync_api import sync_playwright REAL_UA = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " "(KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36") with sync_playwright() as p: browser = p.chromium.launch(headless=True) context = browser.new_context( user_agent=REAL_UA, viewport={"width": 1400, "height": 900}, locale="en-US", timezone_id="America/New_York", ) page = context.new_page() page.set_default_timeout(30_000) # Load landing first to set session page.goto("https://www.hudhomestore.gov/", wait_until="networkidle") time.sleep(2) # Then go to search page.goto("https://www.hudhomestore.gov/searchresult?state=FL", wait_until="networkidle", timeout=30_000) time.sleep(3) print("URL:", page.url) print("Title:", page.title()) print() body_text = page.locator("body").inner_text() print("--- BODY TEXT (first 3000 chars) ---") print(body_text[:3000]) # Save full HTML with open("scripts/_hud_search_fl.html", "w", encoding="utf-8") as f: f.write(page.content()) print(f"\nFull HTML saved: scripts/_hud_search_fl.html") # Dump all