bing

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: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Selectors = struct {
	Captcha        []string
	CookieBtn      string
	ResultItems    string
	Results        string
	Ads            string
	ImageResults   string
	Title          string
	TitleFallbacks []string
	DescPrimary    string
	DescFallback   string
	DescAny        string
	AdTitle        string
}{
	Captcha:   []string{"div.captcha", "div.captcha_header"},
	CookieBtn: "button#bnp_btn_accept",

	ResultItems:  "#b_results > li.b_algo, #b_results > li.b_ad",
	Results:      "li.b_algo",
	Ads:          "li.b_ad",
	ImageResults: "a.iusc, div.iuscp, div.isv",
	Title:        "h2 a",

	TitleFallbacks: []string{"h2", "a[aria-label]"},
	DescPrimary:    "div.b_caption p",
	DescFallback:   "div.b_caption div",
	DescAny:        "p",
	AdTitle:        "h2 a",
}

Selectors is the single source of truth for Bing SERP CSS selectors.

Functions

func BuildImageURL

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

BuildImageURL builds a Bing image search URL from Query fields. It returns an error when the resulting query text is empty.

func BuildURL

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

BuildURL builds a Bing web search URL from Query fields. It returns an error when query text or date parameters are invalid.

func ParseHTML added in v0.7.13

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

ParseHTML parses a Bing SERP HTML document and returns search results. Mirrors the rod-based parser in search.go but operates on a goquery doc. No network I/O.

Types

type Bing

type Bing struct {
	core.Browser
	core.SearchEngineOptions
	// contains filtered or unexported fields
}

Bing implements core.SearchEngine for Bing SERP pages.

func New

func New(browser core.Browser, opts core.SearchEngineOptions) *Bing

New creates a Bing engine instance with browser/runtime options applied.

func (*Bing) Name

func (bing *Bing) Name() string

Name returns the stable engine identifier.

func (*Bing) Search

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

Search executes a Bing web search and returns normalized search results. It may return core.ErrCaptcha or core.ErrSearchTimeout.

func (*Bing) SearchImage

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

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

type BingImageData

type BingImageData struct {
	T      string `json:"t"`      // Title
	Desc   string `json:"desc"`   // Description
	IMGURL string `json:"imgurl"` // Original image URL
	W      int    `json:"w"`      // Width
	H      int    `json:"h"`      // Height
	PURL   string `json:"purl"`   // Page URL
	TURL   string `json:"turl"`   // Thumbnail URL
	MURL   string `json:"murl"`   // Image URL
}

BingImageData represents metadata encoded in the image result `m` attribute.

Jump to

Keyboard shortcuts

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