DuckDuckGo weather extractor missing hourly forecast, precipitation, and icons #51
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
The DuckDuckGo weather extractor (
sites/duckduckgo/weather.go, added in #25) returns aWeatherDatastruct that is missing several fields that mort'sweather2module currently extracts via inline browser scraping:Missing Fields
Hourly forecast - mort extracts hourly temperature/condition data for a ~10-hour window. The extractor's
WeatherDataonly hasForecast []DayForecast(daily), no hourly data.Precipitation percentage - mort extracts the chance of precipitation (e.g., "30% chance of rain") for each day and hour.
DayForecastcurrently only hasDay,HighTemp,LowTemp,Condition- no precipitation field.Weather icons / icon hints - mort extracts
aria-label,title, andaltattributes from weather icon elements to determine the icon type (sunny, cloudy, rain, etc.). The extractor only provides aConditionstring, which works but the icon attributes are more reliable since they come directly from DuckDuckGo's categorization.Proposed Changes
Context
Mort's
pkg/logic/weather2/weather2.gohas ~500 lines of inline DuckDuckGo scraping + regex parsing to extract this data. Once the extractor is complete, mort can replace all of that with a singleduckduckgo.GetWeather()call. Until then, the inline scraping must remain.Related: go-extractor #25, mort #573
Starting work on this. Plan of approach:
HourlyForecaststruct andHourlyfield toWeatherDataPrecipitationfield toDayForecastIconHintfield toDayForecastandHourlyForecastfor icon attribute extractionextractWeather()to scrape hourly data, precipitation percentages, and icon hints from the weather widgetWork finished. PR #52 adds:
HourlyForecaststruct withTime,Temp,Condition,Precipitation,IconHintPrecipitation intfield onDayForecast(-1 if unavailable, matching mort's convention)IconHint stringfield on bothDayForecastandHourlyForecast(reads aria-label > title > alt from icon elements)extractIconHint()helper with attribute priority fallbackI cross-referenced mort's
weather2structs — the field types and -1 sentinel convention align. Mort usesIcon stringonDayForecast; this PR usesIconHintsince the raw value comes from DOM attributes (e.g., "PartlyCloudy") rather than a normalized icon name.