Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Selectors = struct { NoResults []string CaptchaSelectors []string CaptchaMarkers []string Results []string Title []string Desc []string Link []string AdBadge []string MoreResults []string ImageResult []string ImageImg []string ImageTitle []string ImageLink []string }{ NoResults: []string{ "div[class*='no-results']", "[data-testid='no-results']", "div[data-result='no-results']", }, CaptchaSelectors: []string{ "form[action*='anomaly']", "input[name='challenge']", "div[id*='anomaly']", "div[class*='captcha']", }, CaptchaMarkers: []string{ "bots user", "bots use duckduckgo too", "human verification", "unusual traffic", "anomaly", }, Results: []string{ "article[data-testid='result'], article[data-testid='ad'], div[data-testid='result'], div[data-testid='ad']", "article[data-testid='result']", "article[data-testid='ad']", "div[data-testid='result']", "div[data-testid='ad']", "li[data-layout='organic'], li[data-layout='ad']", "li[data-layout='organic']", "li[data-layout='ad']", "div.result", }, Title: []string{ "h2", ".result__title", ".result__a", }, Desc: []string{ "div[data-result='snippet']", ".result__snippet", ".result__body", }, Link: []string{ "a[data-testid='result-title-a']", "a.result__a", "h2 a", "h3 a", }, AdBadge: []string{ "article[data-testid='ad']", "li[data-layout='ad']", "div[data-testid='ad']", "[data-testid='ad-badge']", ".ad-badge", ".result--ad", }, MoreResults: []string{ "#more-results", "[id*='more-result']", }, ImageResult: []string{ "figure[data-testid='image-result']", "figure", }, ImageImg: []string{ "img", }, ImageTitle: []string{ "figcaption a p span", "figcaption span", "figcaption p span", "h3", "span", "p", }, ImageLink: []string{ "figcaption a", "a", }, }
Selectors is the single source of truth for DuckDuckGo SERP CSS selectors.
Order matters: WaitForElements / parseResults try selectors in declared order and stop on the first hit. Put the most specific / current variants first; keep older fallbacks last to absorb DOM rewrites without losing coverage.
Functions ¶
func BuildImageURL ¶
BuildImageURL builds a DuckDuckGo image search URL from Query fields. It returns an error when query text or date parameters are invalid.
Types ¶
type DuckDuckGo ¶
type DuckDuckGo struct {
core.Browser
core.SearchEngineOptions
// contains filtered or unexported fields
}
DuckDuckGo implements core.SearchEngine for DuckDuckGo SERP pages.
func New ¶
func New(browser core.Browser, opts core.SearchEngineOptions) *DuckDuckGo
New creates a DuckDuckGo engine instance with browser/runtime options applied.
func (*DuckDuckGo) Name ¶
func (ddg *DuckDuckGo) Name() string
Name returns the stable engine identifier.
func (*DuckDuckGo) Search ¶
func (ddg *DuckDuckGo) Search(ctx context.Context, query core.Query) (results []core.SearchResult, err error)
Search executes a DuckDuckGo web search and returns normalized search results. It may return core.ErrCaptcha or core.ErrSearchTimeout.
func (*DuckDuckGo) SearchImage ¶
func (ddg *DuckDuckGo) SearchImage(ctx context.Context, query core.Query) ([]core.SearchResult, error)
SearchImage executes a DuckDuckGo image search and returns normalized image results. It may return core.ErrCaptcha or core.ErrSearchTimeout.