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) IsInitialized ¶
Check whether browser instance is already created
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
}
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
Click to show internal directories.
Click to hide internal directories.