Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GoogleDomains = map[string]string{}/* 199 elements not displayed */
GoogleDomains maps language/country hints to Google TLD suffixes used for URL construction.
var Selectors = struct { Captcha string CaptchaPage string CaptchaMarkers []string SoftBlock string NoResults string ResultStats string CookieBtn string NoResultsCard string Results string ResultsBroad string Ad string Link string Title string Cite string SourceName string DescPrimary string DescFallback string DescAny string AnswerBox string AnswerItem string // Image search. ImageResults string ImageLink string ImageLinkFallback string ImageTitle []string }{ Captcha: "[data-sitekey]", CaptchaPage: "form#captcha-form, form[action*='/sorry/'], body[onload*='captcha'], [data-sitekey], .g-recaptcha, script[src*='recaptcha']", CaptchaMarkers: []string{ "detected unusual traffic", "unusual traffic from your computer network", "before you continue", "not a robot", "solve the captcha", }, SoftBlock: "noscript", NoResults: "#botstuff, #topstuff, .mnr-c", ResultStats: "div#result-stats", CookieBtn: "div[role='dialog'][aria-modal] button", NoResultsCard: ".mnr-c", Results: "div.tF2Cxc:not(:has(div.tF2Cxc))", ResultsBroad: "div[data-hveid][data-ved]", Ad: "div[data-text-ad], [data-text-ad]", Link: "a", Title: "h3", Cite: "cite", SourceName: "span.VuuXrf", DescPrimary: "div[data-sncf='1'] div", DescFallback: "div.VwiC3b", DescAny: "div", AnswerBox: "div[data-hveid][data-ulkwtsb] div[data-q]", AnswerItem: "a", ImageResults: "div[data-hveid][data-ved][jsaction]", ImageLink: "a:not([ping])", ImageLinkFallback: "a[href*='imgres']", ImageTitle: []string{"h3", "a"}, }
Selectors is the single source of truth for Google SERP CSS selectors. Both the browser parser (search.go, rod) and HTML parser (search_raw.go, goquery) reference these. When Google changes their DOM, edit here only.
Functions ¶
func BuildImageURL ¶ added in v0.4.1
BuildImageURL builds a Google image search URL from Query fields. It returns an error when the resulting query text is empty or invalid.
func BuildURL ¶
BuildURL builds a Google web search URL from Query fields. It returns an error when the resulting query text is empty or invalid.
Types ¶
type Google ¶
type Google struct {
core.Browser
core.SearchEngineOptions
// contains filtered or unexported fields
}
Google implements core.SearchEngine for Google SERP pages.
func New ¶
func New(browser core.Browser, opts core.SearchEngineOptions) *Google
New creates a Google engine instance with browser/runtime options applied.
func (*Google) Search ¶
func (gogl *Google) Search(ctx context.Context, query core.Query) (results []core.SearchResult, err error)
Search executes a Google web search and returns normalized search results. It may return core.ErrCaptcha or core.ErrSearchTimeout.
func (*Google) SearchImage ¶ added in v0.4.1
SearchImage executes a Google image search and returns normalized image results. It may return core.ErrCaptcha or core.ErrSearchTimeout.