cdp_helper

package module
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arg

type Arg map[string]any

type CdpHelper

type CdpHelper struct {
	// Allocator represents chromedp allocator with cancel func
	Allocator ContextWithCancel
	Browser   ContextWithCancel
	Current   *ContextWithCancel

	Timeout          time.Duration
	TextTimeout      time.Duration
	DownloadTimeout  time.Duration
	EnableScreenshot bool
}

func NewBrowser

func NewBrowser(headless bool) *CdpHelper

func NewRemoteBrowser

func NewRemoteBrowser(option RemoteBrowserOption) *CdpHelper

func (*CdpHelper) Attributes

func (h *CdpHelper) Attributes(sel any, opts ...chromedp.QueryOption) (map[string]string, error)

func (*CdpHelper) AttributesAll

func (h *CdpHelper) AttributesAll(sel any, opts ...chromedp.QueryOption) ([]map[string]string, error)

func (*CdpHelper) ChildNode added in v0.9.4

func (h *CdpHelper) ChildNode(ctx context.Context, parent cdp.NodeID, cssSel string) (context.Context, cdp.NodeID, error)

func (*CdpHelper) ChildNodeTextContent added in v0.9.10

func (h *CdpHelper) ChildNodeTextContent(parent *cdp.Node, cssSel string) (string, error)

func (*CdpHelper) ChildNodes added in v0.9.5

func (h *CdpHelper) ChildNodes(parent *cdp.Node, cssSel string) ([]cdp.NodeID, error)

func (*CdpHelper) Click

func (h *CdpHelper) Click(sel any, opts ...chromedp.QueryOption) error

func (*CdpHelper) ClickChild added in v0.9.4

func (h *CdpHelper) ClickChild(parent *cdp.Node, cssSel string, opts ...chromedp.MouseOption) error

func (*CdpHelper) ComputedStyle added in v0.9.11

func (h *CdpHelper) ComputedStyle(sel any, opts ...chromedp.QueryOption) (map[string]string, error)

func (*CdpHelper) Download

func (h *CdpHelper) Download(path string, isNewTarget bool) (*chan string, context.Context, func(), error)

func (*CdpHelper) FullScreen added in v0.9.21

func (h *CdpHelper) FullScreen() error

func (*CdpHelper) HasChildNode added in v0.9.6

func (h *CdpHelper) HasChildNode(parent *cdp.Node, cssSel string) (cdp.NodeID, bool)

func (*CdpHelper) ListenRequest added in v0.9.21

func (h *CdpHelper) ListenRequest(uri string) chan []byte

func (*CdpHelper) Navigate

func (h *CdpHelper) Navigate(url string) error

func (*CdpHelper) NavigateWithTimeout added in v0.9.20

func (h *CdpHelper) NavigateWithTimeout(url string, timeout time.Duration) error

func (*CdpHelper) NewBlankTab

func (h *CdpHelper) NewBlankTab(targetId string) (*CdpHelper, error)

NewBlankTab returns a new CdpHelper instance, and CdpHelper.Current points to the new tab

func (*CdpHelper) NewBrowserExecutor added in v0.9.4

func (h *CdpHelper) NewBrowserExecutor(ctx context.Context) context.Context

func (*CdpHelper) NewTargetExecutor added in v0.9.4

func (h *CdpHelper) NewTargetExecutor(ctx context.Context) context.Context

func (*CdpHelper) NodeTextContent added in v0.9.10

func (h *CdpHelper) NodeTextContent(sel any, opts ...chromedp.QueryOption) (string, error)

func (*CdpHelper) Nodes

func (h *CdpHelper) Nodes(sel any, opts ...chromedp.QueryOption) ([]*cdp.Node, error)

func (*CdpHelper) Run

func (h *CdpHelper) Run(actions ...chromedp.Action) error

func (*CdpHelper) RunWithTimeout added in v0.9.1

func (h *CdpHelper) RunWithTimeout(t time.Duration, actions ...chromedp.Action) error

func (*CdpHelper) ScreenShot added in v0.9.12

func (h *CdpHelper) ScreenShot(dir string, filename string) error

func (*CdpHelper) SendKeys

func (h *CdpHelper) SendKeys(sel any, v string, opts ...chromedp.QueryOption) error

func (*CdpHelper) SetAttributeValue

func (h *CdpHelper) SetAttributeValue(sel any, name string, value string, opts ...chromedp.QueryOption) error

func (*CdpHelper) SetAttributes

func (h *CdpHelper) SetAttributes(sel any, attributes map[string]string, opts ...chromedp.QueryOption) error

func (*CdpHelper) Sleep

func (h *CdpHelper) Sleep(d time.Duration) error

func (*CdpHelper) Tasks added in v0.9.3

func (h *CdpHelper) Tasks(actions ...chromedp.Action) error

func (*CdpHelper) Upload added in v0.9.15

func (h *CdpHelper) Upload(sel any, files []string, opts ...chromedp.QueryOption) error

func (*CdpHelper) WaitReady

func (h *CdpHelper) WaitReady(sel any, opts ...chromedp.QueryOption) error

func (*CdpHelper) WaitReadyWithTimeout added in v0.9.15

func (h *CdpHelper) WaitReadyWithTimeout(timeout time.Duration, sel any, opts ...chromedp.QueryOption) error

func (*CdpHelper) WithTextTimeout

func (h *CdpHelper) WithTextTimeout(timeout time.Duration)

func (*CdpHelper) WithTimeout

func (h *CdpHelper) WithTimeout(timeout time.Duration)

type ContextWithCancel

type ContextWithCancel struct {
	Context context.Context
	Cancel  context.CancelFunc
}

type DefaultLogger

type DefaultLogger struct {
}

func (*DefaultLogger) Debugf

func (*DefaultLogger) Debugf(format string, args ...any)

func (*DefaultLogger) Errorf

func (*DefaultLogger) Errorf(format string, args ...any)

func (*DefaultLogger) Logf

func (*DefaultLogger) Logf(format string, args ...any)

type Job

type Job interface {
	Prev() ([]Arg, bool)
	Do(arg Arg) bool
	Post(args *[]Arg)
}

type Logger

type Logger interface {
	Errorf(string, ...any)
	Debugf(string, ...any)
}

type RemoteBrowserOption added in v0.9.17

type RemoteBrowserOption struct {
	URL    string
	Logger Logger
}

type Scheduler

type Scheduler struct {
	PrevRetry         bool          // whether retry in prev phase
	PrevRetryTimes    int           // prev phase retry times
	PrevRetryInterval time.Duration // prev phase retry interval
	ErrRetry          bool          // whether retry when error occur
	ErrRetryTimes     int           // retry times when error occur
	Concurrent        bool          // execute do function concurrently
	WaitStep          int
	Done              chan any

	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewScheduler

func NewScheduler() *Scheduler

func (*Scheduler) Schedule added in v0.9.7

func (scheduler *Scheduler) Schedule(job Job) bool

Jump to

Keyboard shortcuts

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