websearch

package
v0.9.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderSogou      = "sogou"
	ProviderBaidu      = "baidu"
	ProviderQuark      = "quark"
	ProviderBing       = "bing"
	ProviderDuckDuckGo = "duckduckgo"
)

Variables

View Source
var ErrNoResults = errors.New("no web search results found")

Functions

This section is empty.

Types

type Config

type Config struct {
	Timeout       time.Duration
	MaxResults    int
	Language      string
	SafeSearch    int
	SafeSearchSet bool
	Providers     []string
	Quick         bool
	HTTPClient    *http.Client

	// ProviderBaseURLs is intended for tests and private deployments that need
	// to point a built-in provider at a controlled compatible endpoint.
	ProviderBaseURLs map[string]string
}

type Result

type Result struct {
	Title       string  `json:"title"`
	URL         string  `json:"url"`
	Snippet     string  `json:"snippet,omitempty"`
	Engine      string  `json:"engine,omitempty"`
	Category    string  `json:"category,omitempty"`
	Score       float64 `json:"score,omitempty"`
	PublishedAt string  `json:"published_at,omitempty"`
}

type SearchRequest

type SearchRequest struct {
	Query string
}

type SearchResponse

type SearchResponse struct {
	Query    string   `json:"query"`
	Provider string   `json:"provider,omitempty"`
	Results  []Result `json:"results"`
}
func Search(ctx context.Context, cfg Config, req SearchRequest) (SearchResponse, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL