Mort's pkg/logic/weather2/weather2.go currently does ~300 lines of inline browser scraping to extract structured weather data from DuckDuckGo's weather widget. It opens https://duckduckgo.com/?q=weather+CITY, waits 3 seconds, then does complex text parsing and attribute extraction from div.react-module article elements.
This should be a proper site extractor in go-extractor's sites/duckduckgo package (or a new sites/duckduckgo/weather sub-package).
Proposed API
packageduckduckgo// or duckduckgo/weathertypeWeatherDatastruct{LocationstringCurrentTempfloat64ConditionstringHighTempfloat64LowTempfloat64HumiditystringWindstringForecast[]DayForecastHourly[]HourlyForecast}func(cConfig)GetWeather(ctxcontext.Context,bextractor.Browser,citystring)(*WeatherData,error)
Benefits
Mort's weather2.go would shrink from ~300 lines to ~20 lines
Other go-extractor consumers get weather data for free
Weather parsing logic is testable independently with mock HTML fixtures
Selector breakage is caught in go-extractor tests, not discovered in production mort
Reference
See mort/pkg/logic/weather2/weather2.go for the current implementation and ParseWeatherFromText() for the text parsing logic.
## Description
Mort's `pkg/logic/weather2/weather2.go` currently does ~300 lines of inline browser scraping to extract structured weather data from DuckDuckGo's weather widget. It opens `https://duckduckgo.com/?q=weather+CITY`, waits 3 seconds, then does complex text parsing and attribute extraction from `div.react-module article` elements.
This should be a proper site extractor in go-extractor's `sites/duckduckgo` package (or a new `sites/duckduckgo/weather` sub-package).
## Proposed API
```go
package duckduckgo // or duckduckgo/weather
type WeatherData struct {
Location string
CurrentTemp float64
Condition string
HighTemp float64
LowTemp float64
Humidity string
Wind string
Forecast []DayForecast
Hourly []HourlyForecast
}
func (c Config) GetWeather(ctx context.Context, b extractor.Browser, city string) (*WeatherData, error)
```
## Benefits
- Mort's weather2.go would shrink from ~300 lines to ~20 lines
- Other go-extractor consumers get weather data for free
- Weather parsing logic is testable independently with mock HTML fixtures
- Selector breakage is caught in go-extractor tests, not discovered in production mort
## Reference
See `mort/pkg/logic/weather2/weather2.go` for the current implementation and `ParseWeatherFromText()` for the text parsing logic.
Implemented in PR #44. Added GetWeather() method with WeatherData and DayForecast types, extracting location, temperature, condition, high/low, humidity, wind, and multi-day forecast from DuckDuckGo's weather widget. Full mock-based test coverage included.
Implemented in PR #44. Added `GetWeather()` method with `WeatherData` and `DayForecast` types, extracting location, temperature, condition, high/low, humidity, wind, and multi-day forecast from DuckDuckGo's weather widget. Full mock-based test coverage included.
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.
Description
Mort's
pkg/logic/weather2/weather2.gocurrently does ~300 lines of inline browser scraping to extract structured weather data from DuckDuckGo's weather widget. It openshttps://duckduckgo.com/?q=weather+CITY, waits 3 seconds, then does complex text parsing and attribute extraction fromdiv.react-module articleelements.This should be a proper site extractor in go-extractor's
sites/duckduckgopackage (or a newsites/duckduckgo/weathersub-package).Proposed API
Benefits
Reference
See
mort/pkg/logic/weather2/weather2.gofor the current implementation andParseWeatherFromText()for the text parsing logic.Implemented in PR #44. Added
GetWeather()method withWeatherDataandDayForecasttypes, extracting location, temperature, condition, high/low, humidity, wind, and multi-day forecast from DuckDuckGo's weather widget. Full mock-based test coverage included.