dom

package
v0.0.0-...-e5d03f5 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package dom provides DOM related functions to parse HTML pages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstChild

func FirstChild(n *html.Node, filters ...Selector) *html.Node

FirstChild travel the tree with the filter specified and returns the first node found.

func NodeAttr

func NodeAttr(n *html.Node, key string) string

NodeAttr returns the attribute of an html node if it exists.

func NodeMarkdown

func NodeMarkdown(n *html.Node) string

NodeMarkdown returns the node's content as a markdown representation.

This is best effort.

func NodeText

func NodeText(n *html.Node) string

NodeText returns the text as processed in HTML.

func YieldChildren

func YieldChildren(n *html.Node, filters ...Selector) iter.Seq[*html.Node]

YieldChildren travel the tree with the filter specified, traversing depth first.

Types

type Selector

type Selector func(*html.Node) bool

Selector is a filter to select nodes in an DOM tree.

func Attr

func Attr(key, val string) Selector

Attr selects element nodes by attribute name and value.

func Class

func Class(className string) Selector

Class selects element nodes by class name.

func ID

func ID(id string) Selector

ID selects nodes by id.

func Tag

func Tag(tagName string) Selector

Tag selects element nodes by tag name.

func Type

func Type(t html.NodeType) Selector

Type selects nodes by type.

Jump to

Keyboard shortcuts

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