web

package
v0.0.0-...-f1aec25 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AOL

type AOL struct {
	// contains filtered or unexported fields
}

func (*AOL) Desc

func (a *AOL) Desc(i int) (string, error)

Desc returns the description of the search result corresponding to i

func (*AOL) Each

func (a *AOL) Each(eachCb func(int) error) error

Each runs eachCb with the index of each search result

func (*AOL) Init

func (a *AOL) Init() error

Init runs requests for Bing search engine

func (a *AOL) Link(i int) (string, error)

Link returns the link to the search result corresponding to i

func (*AOL) Name

func (*AOL) Name() string

Name returns "aol"

func (*AOL) SetKeyword

func (a *AOL) SetKeyword(keyword string)

SetKeyword sets the keyword for searching

func (*AOL) SetPage

func (a *AOL) SetPage(page int)

SetPage sets the page number for searching

func (*AOL) SetUserAgent

func (a *AOL) SetUserAgent(ua string)

SetUserAgent sets the user agent to use for the request

func (*AOL) Title

func (a *AOL) Title(i int) (string, error)

Title returns the title of the search result corresponding to i

type Bing

type Bing struct {
	// contains filtered or unexported fields
}

Bing represents the Bing search engine

func (*Bing) Desc

func (b *Bing) Desc(i int) (string, error)

Desc returns the description of the search result corresponding to i

func (*Bing) Each

func (b *Bing) Each(eachCb func(int) error) error

Each runs eachCb with the index of each search result

func (*Bing) Init

func (b *Bing) Init() error

Init runs requests for Bing search engine

func (b *Bing) Link(i int) (string, error)

Link returns the link to the search result corresponding to i

func (*Bing) Name

func (b *Bing) Name() string

Name returns "bing"

func (*Bing) SetKeyword

func (b *Bing) SetKeyword(keyword string)

SetKeyword sets the keyword for searching

func (*Bing) SetPage

func (b *Bing) SetPage(page int)

SetPage sets the page number for searching

func (*Bing) SetUserAgent

func (b *Bing) SetUserAgent(ua string)

SetUserAgent sets the user agent to use for the request

func (*Bing) Title

func (b *Bing) Title(i int) (string, error)

Title returns the title of the search result corresponding to i

type DDG

type DDG struct {
	// contains filtered or unexported fields
}

DDG represents the DuckDuckGo search engine

func (*DDG) Desc

func (d *DDG) Desc(i int) (string, error)

Desc returns the description of the search result corresponding to i

func (*DDG) Each

func (d *DDG) Each(eachCb func(int) error) error

Each runs eachCb with the index of each search result

func (*DDG) Init

func (d *DDG) Init() error

Init runs requests for the DuckDuckGo search engine

func (d *DDG) Link(i int) (string, error)

Link returns the link to the search result corresponding to i

func (*DDG) Name

func (d *DDG) Name() string

Name returns "ddg"

func (*DDG) SetKeyword

func (d *DDG) SetKeyword(keyword string)

SetKeyword sets the keyword for searching

func (*DDG) SetPage

func (d *DDG) SetPage(page int)

SetPage sets the page number for searching

func (*DDG) SetUserAgent

func (d *DDG) SetUserAgent(ua string)

SetUserAgent sets the user agent for the request

func (*DDG) Title

func (d *DDG) Title(i int) (string, error)

Title returns the title of the search result corresponding to i

type Engine

type Engine interface {
	// Set search keyword for engine
	SetKeyword(string)

	// Set User Agent. If string is empty,
	// an acceptable will should be used.
	SetUserAgent(string)

	// Set page number to search
	SetPage(int)

	// Initialize engine (make requests, set variables, etc.)
	Init() error

	// Run function for each search result,
	// inputting index
	Each(func(int) error) error

	// Get title from index given by Each()
	Title(int) (string, error)
	// Get link from index given by Each()
	Link(int) (string, error)
	// Get description from index given by Each()
	Desc(int) (string, error)

	// Return shortened name of search engine.
	// Should be lowercase (e.g. google, ddg, bing)
	Name() string
}

Engine represents a search engine for web results (not images, shopping, erc.)

type Google

type Google struct {
	// contains filtered or unexported fields
}

Google represents the Google search engine

func (*Google) Desc

func (g *Google) Desc(i int) (string, error)

Desc returns the description of the search result corresponding to i

func (*Google) Each

func (g *Google) Each(eachCb func(int) error) error

Each runs eachCb with the index of each search result

func (*Google) Init

func (g *Google) Init() error

Init runs requests for the Google search engine

func (g *Google) Link(i int) (string, error)

Link returns the link to the search result corresponding to i

func (*Google) Name

func (g *Google) Name() string

Name returns "google"

func (*Google) SetKeyword

func (g *Google) SetKeyword(keyword string)

SetKeyword sets the keyword for searching

func (*Google) SetPage

func (g *Google) SetPage(page int)

SetPage sets the page number for searching

func (*Google) SetUserAgent

func (g *Google) SetUserAgent(ua string)

SetUserAgent sets the user agent for the request

func (*Google) Title

func (g *Google) Title(i int) (string, error)

Title returns the title of the search result corresponding to i

type Options

type Options struct {
	Keyword   string
	UserAgent string
	Page      int
}

Options represents search options

type Result

type Result struct {
	Title   string
	Link    string
	Desc    string
	Engines []string
	Rank    int
}

Result represents a search result

func Search(opts Options, engines ...Engine) ([]*Result, error)

Search searches the given engines concurrently and returns the results

Jump to

Keyboard shortcuts

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