ecosia

package
v0.7.15 Latest Latest
Warning

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

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

Documentation

Overview

Package ecosia implements an Ecosia SERP scraper (web + image search).

Ecosia (https://www.ecosia.org/) is a Berlin-based search engine that proxies results from Bing, Google, and its own EUSP/Staan index (https://staan.ai/) which underlying provider serves a query depends on market and device.

Index

Constants

This section is empty.

Variables

View Source
var Selectors = struct {
	Mainline    string
	Result      string
	Ad          string
	ResultLink  string
	Title       string
	Desc        string
	ImageResult string
	ImageLink   string
	ImageSource string
	ImageDims   string
}{
	Mainline:    "[data-test-id='mainline']",
	Result:      "[data-test-id='mainline-result-web']",
	Ad:          "[data-test-id='mainline-result-ad']",
	ResultLink:  "[data-test-id='result-link']",
	Title:       "[data-test-id='result-title']",
	Desc:        "[data-test-id='result-description']",
	ImageResult: "[data-test-id='images-result']",
	ImageLink:   "[data-test-id='image-result-link']",
	ImageSource: "[data-test-id='image-result-source']",
	ImageDims:   "[data-test-id='image-result-dimensions']",
}

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

Functions

func BuildImageURL

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

BuildImageURL builds an Ecosia image search URL for the supplied query and 0-based page index. Image search lives on /images, not /search. q.Filetype maps to imageType (clipart, photo, line, animatedgif, transparent), not a generic file extension.

Of the six image filters Ecosia exposes (Size, Colour, Type, Time, Layouts, License), only Type (q.Filetype -> imageType) and Time (q.DateInterval -> freshness) are mapped; size/colour/layouts/license are not mapped currently.

func BuildURL

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

BuildURL builds an Ecosia web search URL for the supplied query and 0-based page index. q.LangCode is not encoded — Ecosia takes region from the ECFG cookie / Accept-Language, set via the browser profile.

func ParseHTML

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

ParseHTML parses an Ecosia SERP HTML document and returns search results. No network I/O.

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

Types

type Ecosia

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

Ecosia implements core.SearchEngine for Ecosia SERP pages. Additional documentation at https://support.ecosia.org/article/447-search-features.

func New

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

New creates an Ecosia engine instance with browser/runtime options applied.

func (*Ecosia) Name

func (e *Ecosia) Name() string

Name returns the stable engine identifier.

func (*Ecosia) Search

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

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

func (*Ecosia) SearchImage

func (e *Ecosia) SearchImage(ctx context.Context, query core.Query) (results []core.SearchResult, err error)

SearchImage executes an Ecosia image search and returns normalized image results. It may return core.ErrCaptcha or core.ErrSearchTimeout. query.Start is ignored: per-page card count varies, so callers should drive depth through query.Limit alone.

Jump to

Keyboard shortcuts

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