Documentation
¶
Index ¶
- Variables
- func Must[T any](v T, err error) T
- type Builder
- func (b *Builder) Attr(name string) (string, error)
- func (b *Builder) CSS(selector string) *Builder
- func (b *Builder) CSSAll(selector string) Nodes
- func (b *Builder) Child(index ...int) *Builder
- func (b *Builder) Children() Nodes
- func (b *Builder) Extract(schema Schema) (Result, error)
- func (b *Builder) HTML() (string, error)
- func (b *Builder) HasClass(name string) (bool, error)
- func (b *Builder) Href() (string, error)
- func (b *Builder) Next() *Builder
- func (b *Builder) NextAll() Nodes
- func (b *Builder) NodeType() (html.NodeType, error)
- func (b *Builder) Parent() *Builder
- func (b *Builder) Parents() Nodes
- func (b *Builder) Prev() *Builder
- func (b *Builder) PrevAll() Nodes
- func (b *Builder) Siblings() Nodes
- func (b *Builder) Src() (string, error)
- func (b *Builder) Tag() (string, error)
- func (b *Builder) Text() (string, error)
- func (b *Builder) XPath(expr string) *Builder
- func (b *Builder) XPathAll(expr string) Nodes
- type ExtractionError
- type ExtractorBuilder
- func (eb *ExtractorBuilder) Attr(name string) *StringBuilder
- func (eb *ExtractorBuilder) CSS(sel string) *ExtractorBuilder
- func (eb *ExtractorBuilder) Child(index ...int) *ExtractorBuilder
- func (eb *ExtractorBuilder) HTML() *StringBuilder
- func (eb *ExtractorBuilder) Href() *StringBuilder
- func (eb *ExtractorBuilder) Next() *ExtractorBuilder
- func (eb *ExtractorBuilder) Parent() *ExtractorBuilder
- func (eb *ExtractorBuilder) Prev() *ExtractorBuilder
- func (eb *ExtractorBuilder) Src() *StringBuilder
- func (eb *ExtractorBuilder) Text() *StringBuilder
- func (eb *ExtractorBuilder) XPath(expr string) *ExtractorBuilder
- type Nodes
- func (ns Nodes) Any(fn func(*Builder) bool) (bool, error)
- func (ns Nodes) AttrAll(name string) ([]string, error)
- func (ns Nodes) CSS(selector string) Nodes
- func (ns Nodes) Each(fn func(i int, b *Builder))
- func (ns Nodes) Every(fn func(*Builder) bool) (bool, error)
- func (ns Nodes) ExtractAll(schema Schema) ([]Result, error)
- func (ns Nodes) Filter(fn func(*Builder) bool) Nodes
- func (ns Nodes) First() *Builder
- func (ns Nodes) Get(index int) *Builder
- func (ns Nodes) Last() *Builder
- func (ns Nodes) Len() (int, error)
- func (ns Nodes) None() (bool, error)
- func (ns Nodes) Some() (bool, error)
- func (ns Nodes) TextAll() ([]string, error)
- func (ns Nodes) XPath(expr string) Nodes
- type Page
- type Result
- type Schema
- type StringBuilder
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder wraps a single node with deferred error propagation.
func (*Builder) Child ¶
Child returns the first element child (no args) or the nth element child (one arg). Skips text and comment nodes.
type ExtractionError ¶
ExtractionError holds per-field errors from Extract or ExtractAll. The partial Result is still returned alongside this error.
func (*ExtractionError) Error ¶
func (e *ExtractionError) Error() string
type ExtractorBuilder ¶
type ExtractorBuilder struct {
// contains filtered or unexported fields
}
ExtractorBuilder accumulates a selector chain before a string-producing terminal.
func (*ExtractorBuilder) Attr ¶
func (eb *ExtractorBuilder) Attr(name string) *StringBuilder
func (*ExtractorBuilder) CSS ¶
func (eb *ExtractorBuilder) CSS(sel string) *ExtractorBuilder
func (*ExtractorBuilder) Child ¶
func (eb *ExtractorBuilder) Child(index ...int) *ExtractorBuilder
func (*ExtractorBuilder) HTML ¶
func (eb *ExtractorBuilder) HTML() *StringBuilder
func (*ExtractorBuilder) Href ¶
func (eb *ExtractorBuilder) Href() *StringBuilder
func (*ExtractorBuilder) Next ¶
func (eb *ExtractorBuilder) Next() *ExtractorBuilder
func (*ExtractorBuilder) Parent ¶
func (eb *ExtractorBuilder) Parent() *ExtractorBuilder
func (*ExtractorBuilder) Prev ¶
func (eb *ExtractorBuilder) Prev() *ExtractorBuilder
func (*ExtractorBuilder) Src ¶
func (eb *ExtractorBuilder) Src() *StringBuilder
func (*ExtractorBuilder) Text ¶
func (eb *ExtractorBuilder) Text() *StringBuilder
func (*ExtractorBuilder) XPath ¶
func (eb *ExtractorBuilder) XPath(expr string) *ExtractorBuilder
type Nodes ¶
type Nodes struct {
// contains filtered or unexported fields
}
Nodes wraps a collection of nodes with deferred error propagation.
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page is the document entry point.
type Schema ¶
type Schema map[string]*StringBuilder
Schema maps keys to StringBuilders evaluated per-node at extract time.
type StringBuilder ¶ added in v0.2.0
type StringBuilder struct {
// contains filtered or unexported fields
}
StringBuilder continues the chain after a string-producing step. Transforms are applied in order after extraction.
func (*StringBuilder) Map ¶ added in v0.2.0
func (sb *StringBuilder) Map(fn func(string) string) *StringBuilder
func (*StringBuilder) Replace ¶ added in v0.2.0
func (sb *StringBuilder) Replace(old, new string) *StringBuilder
func (*StringBuilder) TrimSpace ¶ added in v0.2.0
func (sb *StringBuilder) TrimSpace() *StringBuilder
Click to show internal directories.
Click to hide internal directories.