When DuckDuckGo's weather widget displays a weather advisory (e.g. "Wind Advisory"), an extra div element is inserted in the section structure. The weather extractor uses positional CSS selectors (div:first-child and div:nth-child(2)) to locate the header and hourly container, so the advisory shifts these positions and causes:
Current temperature: 0 (derived from empty hourly data)
Hourly forecast: empty array
Humidity/Wind: empty strings
Weekly forecast: unaffected (uses structural ul > div selector)
Observed with "Erie,PA,US" query where a wind advisory is active.
Root Cause
In weather.go, extractWeather() uses:
section.SelectFirst("div:first-child") for the header
section.SelectFirst("div:nth-child(2)") for the hourly container
When an advisory div is inserted (e.g. between header and hourly), div:nth-child(2) matches the advisory instead of the hourly container.
Fix
Replace positional selectors with structural ones:
div:not(:has(ul)) for the header (first div without a list)
div:has(> ul) for the hourly container (the div with a direct ul child)
## Bug
When DuckDuckGo's weather widget displays a weather advisory (e.g. "Wind Advisory"), an extra `div` element is inserted in the section structure. The weather extractor uses positional CSS selectors (`div:first-child` and `div:nth-child(2)`) to locate the header and hourly container, so the advisory shifts these positions and causes:
- **Current temperature**: 0 (derived from empty hourly data)
- **Hourly forecast**: empty array
- **Humidity/Wind**: empty strings
- **Weekly forecast**: unaffected (uses structural `ul > div` selector)
Observed with "Erie,PA,US" query where a wind advisory is active.
## Root Cause
In `weather.go`, `extractWeather()` uses:
- `section.SelectFirst("div:first-child")` for the header
- `section.SelectFirst("div:nth-child(2)")` for the hourly container
When an advisory div is inserted (e.g. between header and hourly), `div:nth-child(2)` matches the advisory instead of the hourly container.
## Fix
Replace positional selectors with structural ones:
- `div:not(:has(ul))` for the header (first div without a list)
- `div:has(> ul)` for the hourly container (the div with a direct `ul` child)
Fix submitted in PR #65. Replaced the positional div:first-child and div:nth-child(2) selectors with structural div:not(:has(ul)) and div:has(> ul) selectors. Added a test case that verifies extraction works correctly with an advisory banner present.
Fix submitted in PR #65. Replaced the positional `div:first-child` and `div:nth-child(2)` selectors with structural `div:not(:has(ul))` and `div:has(> ul)` selectors. Added a test case that verifies extraction works correctly with an advisory banner present.
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.
Bug
When DuckDuckGo's weather widget displays a weather advisory (e.g. "Wind Advisory"), an extra
divelement is inserted in the section structure. The weather extractor uses positional CSS selectors (div:first-childanddiv:nth-child(2)) to locate the header and hourly container, so the advisory shifts these positions and causes:ul > divselector)Observed with "Erie,PA,US" query where a wind advisory is active.
Root Cause
In
weather.go,extractWeather()uses:section.SelectFirst("div:first-child")for the headersection.SelectFirst("div:nth-child(2)")for the hourly containerWhen an advisory div is inserted (e.g. between header and hourly),
div:nth-child(2)matches the advisory instead of the hourly container.Fix
Replace positional selectors with structural ones:
div:not(:has(ul))for the header (first div without a list)div:has(> ul)for the hourly container (the div with a directulchild)Fix submitted in PR #65. Replaced the positional
div:first-childanddiv:nth-child(2)selectors with structuraldiv:not(:has(ul))anddiv:has(> ul)selectors. Added a test case that verifies extraction works correctly with an advisory banner present.