feat: Enhance DuckDuckGo provider with real search tests and logging

This commit is contained in:
wizardchen
2025-11-14 14:25:10 +08:00
parent 527b2d46e9
commit 827276728d
3 changed files with 1323 additions and 1201 deletions
@@ -72,6 +72,10 @@ func (p *DuckDuckGoProvider) searchHTML(ctx context.Context, query string, maxRe
// Use a realistic UA to avoid blocks
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36")
// print curl of request
curlCommand := fmt.Sprintf("curl -X GET '%s' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'", req.URL.String())
logger.Infof(ctx, "Curl of request: %s", curlCommand)
resp, err := p.client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to perform request: %w", err)