memory

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package memory implements the in-memory HTML driver.

Index

Constants

View Source
const DriverName = "memory"

Variables

View Source
var (
	DefaultConcurrency = 1
	DefaultMaxRetries  = 5
	DefaultTimeout     = time.Second * 30
)

Functions

func EvalCSSX

func EvalCSSX(ctx context.Context, el *HTMLElement, expression runtime.String) (runtime.List, error)

func EvalXPathTo

func EvalXPathTo(doc *goquery.Document, selection *goquery.Selection, expression string) (runtime.Value, error)

func EvalXPathToElement

func EvalXPathToElement(doc *goquery.Document, selection *goquery.Selection, expression string) (drivers.HTMLElement, error)

func EvalXPathToNode

func EvalXPathToNode(doc *goquery.Document, selection *goquery.Selection, expression string) (drivers.HTMLNode, error)

func EvalXPathToNodes

func EvalXPathToNodes(doc *goquery.Document, selection *goquery.Selection, expression string) (runtime.List, error)

func EvalXPathToNodesWith

func EvalXPathToNodesWith(selection *goquery.Selection, expression string, mapper func(node *html.Node) (runtime.Value, error)) (runtime.List, error)

func NewHTMLElement

func NewHTMLElement(doc *goquery.Document, node *goquery.Selection) (drivers.HTMLElement, error)

Types

type Driver

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

func New

func New(opts ...Option) *Driver

func (*Driver) Close

func (drv *Driver) Close() error

func (*Driver) Name

func (drv *Driver) Name() string

func (*Driver) Open

func (drv *Driver) Open(ctx context.Context, params drivers.Params) (drivers.HTMLPage, error)

func (*Driver) Parse

func (drv *Driver) Parse(_ context.Context, params drivers.ParseParams) (drivers.HTMLPage, error)

type HTMLDocument

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

func NewHTMLDocument

func NewHTMLDocument(
	node *goquery.Document,
	url string,
	parent drivers.HTMLDocument,
) (*HTMLDocument, error)

func NewRootHTMLDocument

func NewRootHTMLDocument(
	node *goquery.Document,
	url string,
) (*HTMLDocument, error)

func (*HTMLDocument) Clone

func (*HTMLDocument) Close

func (doc *HTMLDocument) Close() error

func (*HTMLDocument) Compare

func (doc *HTMLDocument) Compare(other runtime.Value) int

func (*HTMLDocument) Copy

func (doc *HTMLDocument) Copy() runtime.Value

func (*HTMLDocument) CountBySelector

func (doc *HTMLDocument) CountBySelector(ctx context.Context, selector drivers.QuerySelector) (runtime.Int, error)

func (*HTMLDocument) ExistsBySelector

func (doc *HTMLDocument) ExistsBySelector(ctx context.Context, selector drivers.QuerySelector) (runtime.Boolean, error)

func (*HTMLDocument) Get

func (doc *HTMLDocument) Get(ctx context.Context, key runtime.Value) (runtime.Value, error)

func (*HTMLDocument) GetChildDocuments

func (doc *HTMLDocument) GetChildDocuments(ctx context.Context) (runtime.List, error)

func (*HTMLDocument) GetChildNode

func (doc *HTMLDocument) GetChildNode(ctx context.Context, idx runtime.Int) (runtime.Value, error)

func (*HTMLDocument) GetChildNodes

func (doc *HTMLDocument) GetChildNodes(ctx context.Context) (runtime.List, error)

func (*HTMLDocument) GetElement

func (doc *HTMLDocument) GetElement() drivers.HTMLElement

func (*HTMLDocument) GetName

func (doc *HTMLDocument) GetName() runtime.String

func (*HTMLDocument) GetNodeName

func (doc *HTMLDocument) GetNodeName(_ context.Context) (runtime.String, error)

func (*HTMLDocument) GetNodeType

func (doc *HTMLDocument) GetNodeType(_ context.Context) (runtime.Int, error)

func (*HTMLDocument) GetParentDocument

func (doc *HTMLDocument) GetParentDocument(_ context.Context) (drivers.HTMLDocument, error)

func (*HTMLDocument) GetTitle

func (doc *HTMLDocument) GetTitle() runtime.String

func (*HTMLDocument) GetURL

func (doc *HTMLDocument) GetURL() runtime.String

func (*HTMLDocument) Hash

func (doc *HTMLDocument) Hash() uint64

func (*HTMLDocument) Iterate

func (doc *HTMLDocument) Iterate(_ context.Context) (runtime.Iterator, error)

func (*HTMLDocument) Length

func (doc *HTMLDocument) Length(_ context.Context) (runtime.Int, error)

func (*HTMLDocument) MarshalJSON

func (doc *HTMLDocument) MarshalJSON() ([]byte, error)

func (*HTMLDocument) Query

func (doc *HTMLDocument) Query(ctx context.Context, q runtime.Query) (runtime.List, error)

func (*HTMLDocument) QuerySelector

func (doc *HTMLDocument) QuerySelector(ctx context.Context, selector drivers.QuerySelector) (runtime.Value, error)

func (*HTMLDocument) QuerySelectorAll

func (doc *HTMLDocument) QuerySelectorAll(ctx context.Context, selector drivers.QuerySelector) (runtime.List, error)

func (*HTMLDocument) String

func (doc *HTMLDocument) String() string

func (*HTMLDocument) Type

func (doc *HTMLDocument) Type() runtime.Type

func (*HTMLDocument) Unwrap

func (doc *HTMLDocument) Unwrap() any

func (*HTMLDocument) XPath

func (doc *HTMLDocument) XPath(ctx context.Context, expression runtime.String) (runtime.Value, error)

type HTMLElement

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

func (*HTMLElement) Close

func (el *HTMLElement) Close() error

func (*HTMLElement) Compare

func (el *HTMLElement) Compare(other runtime.Value) int

func (*HTMLElement) Copy

func (el *HTMLElement) Copy() runtime.Value

func (*HTMLElement) CountBySelector

func (el *HTMLElement) CountBySelector(ctx context.Context, selector drivers.QuerySelector) (runtime.Int, error)

func (*HTMLElement) ExistsBySelector

func (el *HTMLElement) ExistsBySelector(_ context.Context, selector drivers.QuerySelector) (runtime.Boolean, error)

func (*HTMLElement) Get

func (el *HTMLElement) Get(ctx context.Context, path runtime.Value) (runtime.Value, error)

func (*HTMLElement) GetAttribute

func (el *HTMLElement) GetAttribute(ctx context.Context, name runtime.String) (runtime.Value, error)

func (*HTMLElement) GetAttributes

func (el *HTMLElement) GetAttributes(ctx context.Context) (runtime.Map, error)

func (*HTMLElement) GetChildNode

func (el *HTMLElement) GetChildNode(ctx context.Context, idx runtime.Int) (runtime.Value, error)

func (*HTMLElement) GetChildNodes

func (el *HTMLElement) GetChildNodes(_ context.Context) (runtime.List, error)

func (*HTMLElement) GetInnerHTML

func (el *HTMLElement) GetInnerHTML(_ context.Context) (runtime.String, error)

func (*HTMLElement) GetInnerHTMLBySelector

func (el *HTMLElement) GetInnerHTMLBySelector(ctx context.Context, selector drivers.QuerySelector) (runtime.String, error)

func (*HTMLElement) GetInnerHTMLBySelectorAll

func (el *HTMLElement) GetInnerHTMLBySelectorAll(ctx context.Context, selector drivers.QuerySelector) (runtime.List, error)

func (*HTMLElement) GetInnerText

func (el *HTMLElement) GetInnerText(_ context.Context) (runtime.String, error)

func (*HTMLElement) GetInnerTextBySelector

func (el *HTMLElement) GetInnerTextBySelector(ctx context.Context, selector drivers.QuerySelector) (runtime.String, error)

func (*HTMLElement) GetInnerTextBySelectorAll

func (el *HTMLElement) GetInnerTextBySelectorAll(ctx context.Context, selector drivers.QuerySelector) (runtime.List, error)

func (*HTMLElement) GetNextElementSibling

func (el *HTMLElement) GetNextElementSibling(_ context.Context) (runtime.Value, error)

func (*HTMLElement) GetNodeName

func (el *HTMLElement) GetNodeName(_ context.Context) (runtime.String, error)

func (*HTMLElement) GetNodeType

func (el *HTMLElement) GetNodeType(_ context.Context) (runtime.Int, error)

func (*HTMLElement) GetParentElement

func (el *HTMLElement) GetParentElement(_ context.Context) (runtime.Value, error)

func (*HTMLElement) GetPreviousElementSibling

func (el *HTMLElement) GetPreviousElementSibling(_ context.Context) (runtime.Value, error)

func (*HTMLElement) GetStyle

func (el *HTMLElement) GetStyle(ctx context.Context, name runtime.String) (runtime.Value, error)

func (*HTMLElement) GetStyles

func (el *HTMLElement) GetStyles(ctx context.Context) (runtime.Map, error)

func (*HTMLElement) GetValue

func (el *HTMLElement) GetValue(_ context.Context) (runtime.Value, error)

func (*HTMLElement) Hash

func (el *HTMLElement) Hash() uint64

func (*HTMLElement) Iterate

func (el *HTMLElement) Iterate(_ context.Context) (runtime.Iterator, error)

func (*HTMLElement) Length

func (el *HTMLElement) Length(ctx context.Context) (runtime.Int, error)

func (*HTMLElement) MarshalJSON

func (el *HTMLElement) MarshalJSON() ([]byte, error)

func (*HTMLElement) Query

func (el *HTMLElement) Query(ctx context.Context, q runtime.Query) (runtime.List, error)

func (*HTMLElement) QuerySelector

func (el *HTMLElement) QuerySelector(_ context.Context, selector drivers.QuerySelector) (runtime.Value, error)

func (*HTMLElement) QuerySelectorAll

func (el *HTMLElement) QuerySelectorAll(ctx context.Context, selector drivers.QuerySelector) (runtime.List, error)

func (*HTMLElement) RemoveAttribute

func (el *HTMLElement) RemoveAttribute(ctx context.Context, name ...runtime.String) error

func (*HTMLElement) RemoveStyle

func (el *HTMLElement) RemoveStyle(ctx context.Context, name ...runtime.String) error

func (*HTMLElement) SetAttribute

func (el *HTMLElement) SetAttribute(ctx context.Context, name, value runtime.String) error

func (*HTMLElement) SetAttributes

func (el *HTMLElement) SetAttributes(ctx context.Context, attrs runtime.Map) error

func (*HTMLElement) SetInnerHTML

func (el *HTMLElement) SetInnerHTML(_ context.Context, value runtime.String) error

func (*HTMLElement) SetInnerHTMLBySelector

func (el *HTMLElement) SetInnerHTMLBySelector(ctx context.Context, selector drivers.QuerySelector, innerHTML runtime.String) error

func (*HTMLElement) SetInnerText

func (el *HTMLElement) SetInnerText(_ context.Context, innerText runtime.String) error

func (*HTMLElement) SetInnerTextBySelector

func (el *HTMLElement) SetInnerTextBySelector(ctx context.Context, selector drivers.QuerySelector, innerText runtime.String) error

func (*HTMLElement) SetStyle

func (el *HTMLElement) SetStyle(ctx context.Context, name, value runtime.String) error

func (*HTMLElement) SetStyles

func (el *HTMLElement) SetStyles(ctx context.Context, newStyles runtime.Map) error

func (*HTMLElement) SetValue

func (el *HTMLElement) SetValue(_ context.Context, value runtime.Value) error

func (*HTMLElement) String

func (el *HTMLElement) String() string

func (*HTMLElement) Type

func (el *HTMLElement) Type() runtime.Type

func (*HTMLElement) Unwrap

func (el *HTMLElement) Unwrap() any

func (*HTMLElement) XPath

func (el *HTMLElement) XPath(_ context.Context, expression runtime.String) (runtime.Value, error)

type HTMLPage

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

func NewHTMLPage

func NewHTMLPage(
	qdoc *goquery.Document,
	url string,
	response drivers.HTTPResponse,
	cookies *drivers.HTTPCookies,
) (*HTMLPage, error)

func (*HTMLPage) Close

func (p *HTMLPage) Close() error

func (*HTMLPage) Compare

func (p *HTMLPage) Compare(other runtime.Value) int

func (*HTMLPage) Copy

func (p *HTMLPage) Copy() runtime.Value

func (*HTMLPage) Get

func (p *HTMLPage) Get(ctx context.Context, key runtime.Value) (runtime.Value, error)

func (*HTMLPage) GetCookies

func (p *HTMLPage) GetCookies(_ context.Context) (*drivers.HTTPCookies, error)

func (*HTMLPage) GetFrame

func (p *HTMLPage) GetFrame(ctx context.Context, idx runtime.Int) (runtime.Value, error)

func (*HTMLPage) GetFrames

func (p *HTMLPage) GetFrames(ctx context.Context) (runtime.List, error)

func (*HTMLPage) GetMainFrame

func (p *HTMLPage) GetMainFrame() drivers.HTMLDocument

func (*HTMLPage) GetResponse

func (p *HTMLPage) GetResponse(_ context.Context) (drivers.HTTPResponse, error)

func (*HTMLPage) GetURL

func (p *HTMLPage) GetURL() runtime.String

func (*HTMLPage) Hash

func (p *HTMLPage) Hash() uint64

func (*HTMLPage) IsClosed

func (p *HTMLPage) IsClosed() runtime.Boolean

func (*HTMLPage) Iterate

func (p *HTMLPage) Iterate(ctx context.Context) (runtime.Iterator, error)

func (*HTMLPage) Length

func (p *HTMLPage) Length(ctx context.Context) (runtime.Int, error)

func (*HTMLPage) MarshalJSON

func (p *HTMLPage) MarshalJSON() ([]byte, error)

func (*HTMLPage) Query

func (p *HTMLPage) Query(ctx context.Context, q runtime.Query) (runtime.List, error)

func (*HTMLPage) String

func (p *HTMLPage) String() string

func (*HTMLPage) Type

func (p *HTMLPage) Type() runtime.Type

func (*HTMLPage) Unwrap

func (p *HTMLPage) Unwrap() any

type Option

type Option func(opts *Options)

func WithAllowedHTTPCode

func WithAllowedHTTPCode(httpCode int) Option

func WithAllowedHTTPCodes

func WithAllowedHTTPCodes(httpCodes []int) Option

func WithConcurrency

func WithConcurrency(value int) Option

func WithCookie

func WithCookie(cookie drivers.HTTPCookie) Option

func WithCookies

func WithCookies(cookies []drivers.HTTPCookie) Option

func WithCustomName

func WithCustomName(name string) Option

func WithCustomTransport

func WithCustomTransport(transport *stdhttp.Transport) Option

func WithDefaultBackoff

func WithDefaultBackoff() Option

func WithExponentialBackoff

func WithExponentialBackoff() Option

func WithHeader

func WithHeader(name string, value []string) Option

func WithHeaders

func WithHeaders(headers *drivers.HTTPHeaders) Option

func WithLinearBackoff

func WithLinearBackoff() Option

func WithMaxRetries

func WithMaxRetries(value int) Option

func WithProxy

func WithProxy(address string) Option

func WithTimeout

func WithTimeout(duration time.Duration) Option

func WithUserAgent

func WithUserAgent(value string) Option

type Options

type Options struct {
	*drivers.Options
	Backoff         pester.BackoffStrategy
	HTTPTransport   *stdhttp.Transport
	HTTPCodesFilter []compiledStatusCodeFilter
	MaxRetries      int
	Concurrency     int
	Timeout         time.Duration
}

func NewOptions

func NewOptions(setters []Option) *Options

Jump to

Keyboard shortcuts

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