feat: add Brave web search scraper engine
New brave.go: scrapes https://search.brave.com directly. Extracts title, URL, snippet, and favicon from Brave's HTML. No API key required. Rename existing BraveAPIEngine (was BraveEngine) to avoid collision with the new scraper. API engine stays as 'braveapi', scraper as 'brave'.
This commit is contained in:
parent
994d27ff7f
commit
2d22a8cdbb
4 changed files with 179 additions and 6 deletions
|
|
@ -33,16 +33,16 @@ import (
|
|||
// BraveEngine implements the Brave Web Search API.
|
||||
// Required: BRAVE_API_KEY env var or config.
|
||||
// Optional: BRAVE_ACCESS_TOKEN to gate requests.
|
||||
type BraveEngine struct {
|
||||
type BraveAPIEngine struct {
|
||||
client *http.Client
|
||||
apiKey string
|
||||
accessGateToken string
|
||||
resultsPerPage int
|
||||
}
|
||||
|
||||
func (e *BraveEngine) Name() string { return "braveapi" }
|
||||
func (e *BraveAPIEngine) Name() string { return "braveapi" }
|
||||
|
||||
func (e *BraveEngine) Search(ctx context.Context, req contracts.SearchRequest) (contracts.SearchResponse, error) {
|
||||
func (e *BraveAPIEngine) Search(ctx context.Context, req contracts.SearchRequest) (contracts.SearchResponse, error) {
|
||||
if e == nil || e.client == nil {
|
||||
return contracts.SearchResponse{}, errors.New("brave engine not initialized")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue