core

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCaptcha = errors.New("captcha detected")
View Source
var ErrSearchTimeout = errors.New("timeout. Cannot find element on page")

Functions

func ConvertSearchResultsMap added in v0.4.1

func ConvertSearchResultsMap(searchResultsMap map[string]SearchResult) *[]SearchResult

func InitLogger

func InitLogger(isVerbose, isDebug bool)

Types

type Browser

type Browser struct {
	BrowserOpts

	CaptchaSolver *CaptchaSolver
	// contains filtered or unexported fields
}

func NewBrowser

func NewBrowser(opts BrowserOpts) (*Browser, error)

func (*Browser) Close

func (b *Browser) Close() error

func (*Browser) IsInitialized

func (b *Browser) IsInitialized() bool

Check whether browser instance is already created

func (*Browser) Navigate

func (b *Browser) Navigate(URL string) (*rod.Page, error)

Open URL

type BrowserOpts

type BrowserOpts struct {
	IsHeadless          bool          // Use browser interface
	IsLeakless          bool          // Force to kill browser
	Timeout             time.Duration // Timeout
	LanguageCode        string
	WaitRequests        bool          // Wait requests to complete after navigation
	LeavePageOpen       bool          // Leave pages and browser open
	WaitLoadTime        time.Duration // Time to wait till page loads
	CaptchaSolverApiKey string        // 2Captcha api key
	ProxyURL            string        // Proxy URL
	Insecure            bool          // Allow insecure TLS connections
	UseStealth          bool          // Use go-rod stealth plugin

}

func (*BrowserOpts) Check added in v0.2.1

func (o *BrowserOpts) Check()

Initialize browser parameters with default values if they are not set

type CaptchaSolver added in v0.4.1

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

func NewSolver added in v0.4.1

func NewSolver(apikey string) *CaptchaSolver

func (*CaptchaSolver) SolveReCaptcha2 added in v0.4.1

func (cs *CaptchaSolver) SolveReCaptcha2(sitekey, pageUrl, dataS string) (string, error)

type Query

type Query struct {
	Text         string
	LangCode     string // eg. EN, ES, RU...
	DateInterval string // format: YYYYMMDD..YYYMMDD - 20181010..20231010
	Filetype     string // File extension to search.
	Site         string // Search site
	Limit        int    // Limit the number of results
	Answers      bool   // Include question and answers from SERP page to results with negative indexes
	ProxyURL     string // Proxy URL for raw requests
	Insecure     bool   // Allow insecure TLS connections
}

func (*Query) InitFromContext

func (searchQuery *Query) InitFromContext(reqCtx *fiber.Ctx) error

func (Query) IsEmpty

func (q Query) IsEmpty() bool

type SearchEngine

type SearchEngine interface {
	Search(Query) ([]SearchResult, error)
	SearchImage(Query) ([]SearchResult, error)
	IsInitialized() bool
	Name() string
	GetRateLimiter() *rate.Limiter
}

type SearchEngineOptions added in v0.2.1

type SearchEngineOptions struct {
	RateRequests    int   `mapstructure:"rate_requests"`
	RateTime        int64 `mapstructure:"rate_seconds"`
	RateBurst       int   `mapstructure:"rate_burst"`
	SelectorTimeout int64 `mapstructure:"selector_timeout"` // CSS selector timeout in seconds
	IsSolveCaptcha  bool  `mapstructure:"captcha"`
}

func (*SearchEngineOptions) GetRatelimit added in v0.2.1

func (o *SearchEngineOptions) GetRatelimit() time.Duration

func (*SearchEngineOptions) GetSelectorTimeout added in v0.2.1

func (o *SearchEngineOptions) GetSelectorTimeout() time.Duration

func (*SearchEngineOptions) Init added in v0.2.1

func (o *SearchEngineOptions) Init()

type SearchResult

type SearchResult struct {
	Rank        int    `json:"rank"`
	URL         string `json:"url"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Ad          bool   `json:"ad"`
}

func DeduplicateResults added in v0.4.1

func DeduplicateResults(results []SearchResult) []SearchResult

type Server

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

func NewServer

func NewServer(host string, port int, searchEngines ...SearchEngine) *Server

func (*Server) Listen

func (s *Server) Listen() error

func (*Server) Shutdown

func (s *Server) Shutdown() error

Jump to

Keyboard shortcuts

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