selector

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package selector provides CSS and XPath selector engines for HTML documents. It supports standard CSS selectors via cascadia, XPath via antchfx/htmlquery, and custom pseudo-elements (::text, ::attr()) matching Scrapy/Parsel syntax.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSS

func CSS(root *parser.Adaptable, sel string) ([]*parser.Adaptable, error)

CSS selects elements matching a CSS selector from the given root.

func CSSAttr

func CSSAttr(root *parser.Adaptable, sel, attr string) ([]string, error)

CSSAttr extracts attribute values from elements matching a CSS selector with ::attr(name) pseudo-element.

func CSSFirst

func CSSFirst(root *parser.Adaptable, sel string) (*parser.Adaptable, error)

CSSFirst selects the first element matching a CSS selector.

func CSSText

func CSSText(root *parser.Adaptable, sel string) ([]string, error)

CSSText extracts text from elements matching a CSS selector with ::text pseudo-element.

func XPath

func XPath(root *parser.Adaptable, expr string) ([]*parser.Adaptable, error)

XPath selects elements matching an XPath expression from the given root. This is a simplified XPath implementation supporting common patterns.

func XPathFirst

func XPathFirst(root *parser.Adaptable, expr string) (*parser.Adaptable, error)

XPathFirst selects the first element matching an XPath expression.

Types

type PseudoResult

type PseudoResult struct {
	Nodes []*parser.Adaptable
	Texts []string // populated for ::text or ::attr()
}

PseudoResult holds the result of a pseudo-element extraction.

Jump to

Keyboard shortcuts

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