TheSethRose/Bay-Area-Scraper

GitHub: TheSethRose/Bay-Area-Scraper

一个配置驱动的旧金山湾区多县房产评估师地块数据抓取工具,支持通过地址查询并提取APN、建筑面积、价值等结构化信息。

Stars: 0 | Forks: 0

# 湾区房产数据抓取器 基于配置驱动的旧金山湾区多县房产数据提取工具。 从各县数据源提取评估师地块数据——APN、地址、建筑面积、建造年份、土地/改良价值。 ## 工作原理 ``` scraper.py ← entry point drivers/ ← core engines (3 patterns cover all 9 counties) arcgis_rest.py ← ArcGIS REST API (Contra Costa, Solano) html_form.py ← traditional HTML form POST + table parse browser.py ← nodriver browser for JS/Cloudflare sites counties/ ← per-county configs (TOML), ~15 lines each contra_costa.toml ← ✅ working alameda.toml marin.toml napa.toml san_francisco.toml san_mateo.toml santa_clara.toml solano.toml sonoma.toml plugins/ ← optional per-county overrides for custom logic (county_name.py) ← loaded automatically if it exists output/ ← JSON results saved here ``` ## 使用方法 ``` # 按 county slug + address 搜索 python scraper.py contra_costa "63 Mission Ln, Walnut Creek, CA" --save # 保存结果到 output/ python scraper.py alameda "123 Main St, Oakland, CA" --save # 限制结果 python scraper.py contra_costa "Main St, Walnut Creek, CA" --max-results 3 ``` ## 添加新县 1. 创建 `counties/.toml` —— 选择一个 driver 并配置选择器/字段映射 2. 如果标准的 driver 模式不适用,请创建 `plugins/.py` 并包含可选的 `search()`、`normalize_address()` 或 `post_process()` 钩子 3. 运行并迭代 ### 配置结构 ``` name = "County Name" state = "CA" driver = "arcgis_rest" # or "html_form" or "browser" # Driver 特定 config... service_url = "https://..." field_map = { apn = "APN", address = "SITUS_ADDRESS", ... } ``` ### 插件钩子示例 ``` # plugins/my_county.py — 超出通用 driver 处理范围的自定义逻辑 def normalize_address(address): """Clean up address format for this county's search.""" return address.upper().replace("AVENUE", "AVE") def post_process(result, config): """Enrich results with county-specific logic.""" for prop in result.get("properties", []): if prop.get("assessor_url"): # Fetch additional detail page pass return result ``` ## 各县状态 | 县 | Driver | 状态 | |---|---|---| | Contra Costa | arcgis_rest | ✅ 正常工作 | | San Francisco | socrata | ✅ 正常工作 (data.sfgov.org) | | Alameda | browser | Blazor Server,需要调整浏览器配置 | | San Mateo | browser | Cloudflare,需要调整浏览器配置 | | Santa Clara | browser | Cloudflare,需要调整浏览器配置 | | Marin | browser | Cloudflare,需要调整浏览器配置 | | Napa | browser | MBC/Cloudflare,需要调整浏览器配置 | | Solano | arcgis_rest | Service URL 需要验证 | | Sonoma | browser | ParcelQuest 重定向,需要调整浏览器配置 | ## 环境要求 - Python 3.11+(使用 `tomllib`) - `nodriver` —— 仅用于 browser-driver 县 ``` pip install nodriver ``` ## 许可证 MIT
标签:ArcGIS REST API, Python, Python安全, URL抓取, 公共记录, 房地产数据, 数据抓取, 无后门, 逆向工具