Read data from a Weather Underground personal weather station - temperature, feels-like (wind chill or heat index), dewpoint, humidity, wind and pressure - from the returned api request's JSON.
- Python 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .gitignore | ||
| .python-version | ||
| main.py | ||
| pyproject.toml | ||
| README.md | ||
| uv.lock | ||
| wunderground_scraper.py | ||
Weather Underground scraper
Built with Claude: https://claude.ai/code/session_01RVqY2qqn2TPjqZPaMBCTxv
Setup
sudo apt install libnss3 libnspr4
uv sync
uv run playwright install chromium
Usage
uv run python wunderground_scraper.py KCASANFR2249
uv run python wunderground_scraper.py KCASANFR2249 --json
uv run python wunderground_scraper.py KCASANFR2249 --headed
Other options: --timeout SECONDS, --user-agent STRING, --debug-dir DIR (pass '' to disable).
How it gets the reading
- API capture (preferred): while the dashboard loads, the scraper listens for the page's own request to
api.weather.com/v2/pws/observations/currentand reads temperature, feels-like (wind chill or heat index), dewpoint, humidity, wind and pressure from the JSON. This keeps working when Wunderground restyles the page. - DOM fallback: the original
.main-temp lib-display-unit span.wu-valueselector.
The output says which one it used: [via api] or [via dom].
When it fails
It prints a diagnosis instead of a generic timeout, and saves debug/<station>-<timestamp>.png, .html and .txt:
- HTTP 403/429 or "Access Denied" page: bot/rate-limit blocking (Akamai). Try
--headed, wait a while, or run it from another IP. - API call returned no temperature: the station is offline or not reporting.
- Dashboard never booted, no API call made: the page itself changed; check the screenshot.