Add OpenSearch and SearchPage functionality for DuckDuckGo
Introduced the `OpenSearch` method and `SearchPage` interface to streamline search operations and allow for loading more results dynamically. Updated dependencies and modified the DuckDuckGo CLI to utilize these enhancements.
This commit is contained in:
@@ -3,11 +3,11 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/urfave/cli/v3"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/urfave/cli/v3"
|
||||
"time"
|
||||
|
||||
"gitea.stevedudenhoeffer.com/steve/go-extractor/cmd/browser/pkg/browser"
|
||||
"gitea.stevedudenhoeffer.com/steve/go-extractor/sites/duckduckgo"
|
||||
@@ -58,6 +58,7 @@ func deferClose(cl io.Closer) {
|
||||
func main() {
|
||||
var flags []cli.Flag
|
||||
|
||||
flags = append(flags, browser.Flags...)
|
||||
flags = append(flags, Flags...)
|
||||
|
||||
cli := &cli.Command{
|
||||
@@ -81,13 +82,24 @@ func main() {
|
||||
return fmt.Errorf("failed to create browser: %w", err)
|
||||
}
|
||||
|
||||
res, err := c.Search(ctx, b, query)
|
||||
|
||||
search, err := c.OpenSearch(ctx, b, query)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to search: %w", err)
|
||||
return fmt.Errorf("failed to open search: %w", err)
|
||||
}
|
||||
|
||||
fmt.Println(res)
|
||||
defer deferClose(search)
|
||||
|
||||
res := search.GetResults()
|
||||
fmt.Println("Results:", res)
|
||||
|
||||
err = search.LoadMore()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load more: %w", err)
|
||||
}
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
res = search.GetResults()
|
||||
fmt.Println("Results:", res)
|
||||
|
||||
return nil
|
||||
},
|
||||
|
Reference in New Issue
Block a user