google

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GoogleDomains = map[string]string{}/* 199 elements not displayed */

GoogleDomains maps language/country hints to Google TLD suffixes used for URL construction.

View Source
var Selectors = struct {
	Captcha      string
	ResultStats  string
	CookieBtn    string
	Results      string
	ResultsBroad string
	Ad           string
	Link         string
	Title        string
	DescPrimary  string
	DescFallback string
	DescAny      string
	AnswerBox    string
	AnswerItem   string

	// Image search.
	ImageResults      string
	ImageLink         string
	ImageLinkFallback string
	ImageTitle        []string
}{
	Captcha:     "div[data-sitekey]",
	ResultStats: "div#result-stats",
	CookieBtn:   "div[role='dialog'][aria-modal] button",

	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",
	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

func BuildImageURL(q core.Query) (string, error)

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

func BuildURL(q core.Query) (string, error)

BuildURL builds a Google web search URL from Query fields. It returns an error when the resulting query text is empty or invalid.

func ParseHTML added in v0.7.13

func ParseHTML(r io.Reader) ([]core.SearchResult, error)

ParseHTML parses a Google SERP HTML document and returns search results. It is the pure parser used by both raw HTTP search and parse endpoints.

func Search(ctx context.Context, query core.Query) (results []core.SearchResult, err error)

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) Name

func (gogl *Google) Name() string

Name returns the stable engine identifier.

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

func (gogl *Google) SearchImage(ctx context.Context, query core.Query) ([]core.SearchResult, error)

SearchImage executes a Google image search and returns normalized image results. It may return core.ErrCaptcha or core.ErrSearchTimeout.

type SourceImage added in v0.4.1

type SourceImage struct {
	PageURL     string
	OriginalURL string
	Width       string
	Height      string
}

SourceImage contains parsed Google image metadata extracted from result links.

Jump to

Keyboard shortcuts

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