Replace positional CSS selectors (div:first-child, div:nth-child(2)) with structural ones (div:not(:has(ul)), div:has(> ul)) so the weather extractor works when DuckDuckGo inserts advisory banners (e.g. wind advisory for Erie, PA)
Add TestExtractWeather_WithAdvisory test case verifying extraction succeeds with an advisory div present
Root Cause
The hourly container was located with div:nth-child(2), which breaks when an advisory banner inserts an extra div before it. The weekly forecast was unaffected because it already used the structural selector ul > div.
## Summary
- Replace positional CSS selectors (`div:first-child`, `div:nth-child(2)`) with structural ones (`div:not(:has(ul))`, `div:has(> ul)`) so the weather extractor works when DuckDuckGo inserts advisory banners (e.g. wind advisory for Erie, PA)
- Add `TestExtractWeather_WithAdvisory` test case verifying extraction succeeds with an advisory div present
## Root Cause
The hourly container was located with `div:nth-child(2)`, which breaks when an advisory banner inserts an extra `div` before it. The weekly forecast was unaffected because it already used the structural selector `ul > div`.
## Test Plan
- [x] All existing weather tests pass
- [x] New `TestExtractWeather_WithAdvisory` test passes
- [x] Full `go test ./...` passes
Fixes #64
The weather extractor used positional CSS selectors (div:first-child,
div:nth-child(2)) to locate the header and hourly container within the
widget section. When DuckDuckGo inserts advisory banners (e.g. wind
advisory), the extra div shifts positions and breaks extraction of
current temp, hourly data, humidity, and wind.
Replace with structural selectors:
- div:not(:has(ul)) for the header (first div without a list)
- div:has(> ul) for the hourly container (div with direct ul child)
These match elements by their content structure rather than position,
so advisory banners no longer break extraction.
Fixes#64
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
div:first-child,div:nth-child(2)) with structural ones (div:not(:has(ul)),div:has(> ul)) so the weather extractor works when DuckDuckGo inserts advisory banners (e.g. wind advisory for Erie, PA)TestExtractWeather_WithAdvisorytest case verifying extraction succeeds with an advisory div presentRoot Cause
The hourly container was located with
div:nth-child(2), which breaks when an advisory banner inserts an extradivbefore it. The weekly forecast was unaffected because it already used the structural selectorul > div.Test Plan
TestExtractWeather_WithAdvisorytest passesgo test ./...passesFixes #64