common

package
v0.0.0-...-af4f867 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrNameStyle = "style"
)
View Source
const RandomUserAgent = "*"

Variables

View Source
var (
	ErrReadOnly    = runtime.Error(runtime.ErrInvalidOperation, "read only")
	ErrInvalidPath = runtime.Error(runtime.ErrInvalidOperation, "invalid path")
)
View Source
var Attributes = []string{}/* 151 elements not displayed */

Functions

func CastHTMLDocument

func CastHTMLDocument(value runtime.Value) (drivers.HTMLDocument, error)

func CastHTMLElement

func CastHTMLElement(value runtime.Value) (drivers.HTMLElement, error)

func CloseAll

func CloseAll(logger zerolog.Logger, closers []io.Closer, msg string)

func CollectFrames

func CollectFrames(ctx context.Context, receiver runtime.List, doc drivers.HTMLDocument) error

CollectFrames recursively collects all frames from the given document and appends them to the receiver list. It first appends the current document to the receiver list, then retrieves its child documents and calls itself for each child.

func DeserializeStyles

func DeserializeStyles(ctx context.Context, input runtime.String) (*runtime.Object, error)

func FromHTMLType

func FromHTMLType(nt html.NodeType) int

func GetInDocument

func GetInDocument(ctx context.Context, key runtime.Value, doc drivers.HTMLDocument) (runtime.Value, error)

func GetInElement

func GetInElement(ctx context.Context, key runtime.Value, el drivers.HTMLElement) (runtime.Value, error)

func GetInNode

func GetInNode(ctx context.Context, key runtime.Value, node drivers.HTMLNode) (runtime.Value, error)

func GetInPage

func GetInPage(ctx context.Context, key runtime.Value, page drivers.HTMLPage) (runtime.Value, error)

func GetUserAgent

func GetUserAgent(val string) string

func IsAttribute

func IsAttribute(name string) bool

func IsEmptyValue

func IsEmptyValue(value runtime.Value) bool

func IsNotFound

func IsNotFound(err error) bool

func LoggerWithName

func LoggerWithName(ctx zerolog.Context, name string) zerolog.Context

func NewIterator

func NewIterator(
	node drivers.HTMLElement,
) (runtime.Iterator, error)

func PathToString

func PathToString(path []runtime.Value) string

func SerializeStyles

func SerializeStyles(ctx context.Context, styles runtime.Map) (runtime.String, error)

func SetInDocument

func SetInDocument(ctx context.Context, key runtime.Value, doc drivers.HTMLDocument, value runtime.Value) error

func SetInElement

func SetInElement(ctx context.Context, key runtime.Value, el drivers.HTMLElement, value runtime.Value) error

func SetInPage

func SetInPage(ctx context.Context, key runtime.Value, page drivers.HTMLPage, value runtime.Value) error

func ToHTMLType

func ToHTMLType(input int) html.NodeType

func ToRuntimeStringSlice

func ToRuntimeStringSlice(ctx context.Context, input runtime.Value) ([]runtime.String, error)

Types

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

func (*Iterator) HasNext

func (iter *Iterator) HasNext(ctx context.Context) (bool, error)

func (*Iterator) Next

func (iter *Iterator) Next(ctx context.Context) (runtime.Value, runtime.Value, error)

type LazyValue

type LazyValue struct {
	// contains filtered or unexported fields
}

LazyValue represents a value with late initialization

func NewLazyValue

func NewLazyValue(factory LazyValueFactory) *LazyValue

func (*LazyValue) Mutate

func (lv *LazyValue) Mutate(ctx context.Context, mutator func(v runtime.Value, err error))

Mutate safely mutates an underlying value. Loads a value if it's not ready. Thread safe.

func (*LazyValue) MutateIfReady

func (lv *LazyValue) MutateIfReady(mutator func(v runtime.Value, err error))

MutateIfReady safely mutates an underlying value only if it's ready.

func (*LazyValue) Read

func (lv *LazyValue) Read(ctx context.Context) (runtime.Value, error)

Read returns an underlying value. Not thread safe. Should not mutated. @returns (Value) - Underlying value if successfully loaded, otherwise error

func (*LazyValue) Ready

func (lv *LazyValue) Ready() bool

Ready indicates whether the value is ready. @returns (Boolean) - Boolean value indicating whether the value is ready.

func (*LazyValue) Reload

func (lv *LazyValue) Reload(ctx context.Context)

Reload resets the storage and loads data.

func (*LazyValue) Reset

func (lv *LazyValue) Reset()

Reset resets the storage. Next call of Read will trigger the factory function again.

type LazyValueFactory

type LazyValueFactory func(ctx context.Context) (runtime.Value, error)

LazyValueFactory represents a value initializer

type QueryKind

type QueryKind string
const (
	CSSQuery   QueryKind = "css"
	XPathQuery QueryKind = "xpath"
)

func ToQueryKind

func ToQueryKind(s string) QueryKind

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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