refactor: Deduplicate DuckDuckGo result extraction logic #14
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?
Parent: #3
Description
The result extraction logic in
sites/duckduckgo/duckduckgo.go:99-131(Search()) is nearly identical tosites/duckduckgo/page.go:24-54(GetResults()). Both iterate overarticle[id^="r1-"]elements and extract URL, title, and description with the same selectors.Search()should usesearchPage.GetResults()internally instead of duplicating the extraction logic.Fix
Refactor
Search()to useOpenSearch()+GetResults():Starting work on this as part of PR 9 (also includes #13). Will extract shared DuckDuckGo result parsing into a helper function.
Work finished — extracted duplicated DuckDuckGo result parsing into shared
extractResults()helper. Merged in PR #40.Resolved by PR #40 —
Search()now delegates toOpenSearch()+GetResults(), eliminating the duplicated result extraction logic.