html

package
v0.0.0-...-9976945 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(root *html.Node, selectors []string) ([]*html.Node, error)

func ParseAttrMatcher

func ParseAttrMatcher(selector *CSSselector, s scanner.Scanner) error

Parse an attribute matcher e.g. `[attr^="http"]`

func ParseClassMatcher

func ParseClassMatcher(selector *CSSselector, s scanner.Scanner) error

Parse a class matcher e.g. `.btn`

func ParseHTML

func ParseHTML(r io.Reader, cs string) (*html.Node, error)

ParseHTML parses the HTML while rendering the charset

func ParseIdMatcher

func ParseIdMatcher(selector *CSSselector, s scanner.Scanner) error

Parse an id matcher e.g. `#my-picture`

func ParsePseudo

func ParsePseudo(selector *CSSselector, s scanner.Scanner) error

Parse the selector after ':'

func ParseTagMatcher

func ParseTagMatcher(selector *CSSselector, s scanner.Scanner) error

Parse the initial tag e.g. `div`

func Select

func Select(s selector) selectorFunc

func SelectFromChildren

func SelectFromChildren(s selector) selectorFunc

SelectFromChildren selects the children of the nodes Defined for the '+' selector

func SelectNextSibling

func SelectNextSibling(s selector) selectorFunc

SelectNextSibling selects the next sibling of the node Defined for the '>' selector

Types

type CSSselector

type CSSselector struct {
	Tag    string
	Attrs  map[string]*regexp.Regexp
	Pseudo PseudoClass
}

func ParseSelector

func ParseSelector(cmd string) (selector CSSselector, err error)

ParseSelector parses a selector e.g. `div#my-button.btn[href^="http"]`

func (CSSselector) Match

func (s CSSselector) Match(node *html.Node) bool

Match matches a node based on a CSS selector

type PseudoClass

type PseudoClass func(*html.Node) bool

Jump to

Keyboard shortcuts

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