htmlparser

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	Root *Node
}

Document represents a parsed HTML document.

func Parse

func Parse(htmlStr string) (*Document, error)

Parse parses an HTML string into a Document.

func (*Document) FindByHID

func (d *Document) FindByHID(hid string) *Node

FindByHID finds the first element with the given data-hid.

func (*Document) FindByTestID

func (d *Document) FindByTestID(testid string) *Node

FindByTestID finds the first element with the given data-testid.

type Node

type Node struct {
	Type     html.NodeType
	Tag      string
	Attrs    map[string]string
	Children []*Node
	Text     string
}

Node represents an HTML node.

func (*Node) FindByAttr

func (n *Node) FindByAttr(key, value string) *Node

FindByAttr finds the first element with the given attribute value.

func (*Node) GetAttr

func (n *Node) GetAttr(key string) string

GetAttr returns the value of an attribute.

func (*Node) TextContent

func (n *Node) TextContent() string

TextContent returns the concatenated text content of the node and its descendants.

Jump to

Keyboard shortcuts

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