cdp

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 8 Imported by: 1 module, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

cdp

chromedp wrapper

Documentation

Overview

Package cdp 对 github.com/chromedp/chromedp 做一层常用封装

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct{}

func NewAction

func NewAction() *Action

func (*Action) FullScreen

func (self *Action) FullScreen(quality int64, buf *[]byte) chromedp.Action

func (*Action) SetCookies

func (self *Action) SetCookies(cookies []*network.CookieParam) chromedp.Action

type CDP

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

func NewCDP

func NewCDP() *CDP

func (*CDP) Run

func (self *CDP) Run(actions ...chromedp.Action) error

Run 启动并执行chrome

func (*CDP) WithAction

func (self *CDP) WithAction(act chromedp.Action) *CDP

WithAction 添加自定义Action

func (*CDP) WithActionFunc

func (self *CDP) WithActionFunc(f chromedp.ActionFunc) *CDP

WithActionFunc 接受一个func,用户自定义丰富的Action过程

func (*CDP) WithBrowserDebugLog

func (self *CDP) WithBrowserDebugLog(f func(string, ...interface{})) *CDP

WithBrowserLog 设置启动浏览器日志

func (*CDP) WithBrowserErrorLog

func (self *CDP) WithBrowserErrorLog(f func(string, ...interface{})) *CDP

func (*CDP) WithBrowserInfoLog

func (self *CDP) WithBrowserInfoLog(f func(string, ...interface{})) *CDP

func (*CDP) WithChromePath

func (self *CDP) WithChromePath(path string) *CDP

WithChromePath 设置chrome的执行路径

func (*CDP) WithDevice

func (self *CDP) WithDevice(dev chromedp.Device) *CDP

WithDevice 设置设备类型

func (*CDP) WithEnv

func (self *CDP) WithEnv(vars ...string) *CDP

WithEnv 设置启动时的环境变量

func (*CDP) WithFlag

func (self *CDP) WithFlag(name string, value interface{}) *CDP

WithFlag 设置启动时的flag

func (*CDP) WithSleep

func (self *CDP) WithSleep(sl time.Duration) *CDP

WithSleep 设置chromedp在渲染过程中的睡眠时间 通常用于等待静态资源加载的过程中

func (*CDP) WithTimeout

func (self *CDP) WithTimeout(t time.Duration) *CDP

WithTimeout 设置整体执行时长

func (*CDP) WithUserAgent

func (self *CDP) WithUserAgent(ua string) *CDP

WithUserAgent 设置UserAgent

func (*CDP) WithViewport

func (self *CDP) WithViewport(width, height int64) *CDP

WithViewport 设置展示区域的尺寸

func (*CDP) WithWindowSize

func (self *CDP) WithWindowSize(width, height int) *CDP

WithWindowSize 设置浏览器窗口的宽高

func (*CDP) WithoutHeadless

func (self *CDP) WithoutHeadless() *CDP

WithoutHeadless 设置关闭headless 设置了这个选项后,chromedp在执行过程中会启动chrome的GUI,用于观察chrome的行为

type Helper

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

func NewHelper

func NewHelper(url string) *Helper

func (*Helper) FullScreen

func (self *Helper) FullScreen(quality int64, buf *[]byte) error

func (*Helper) Init

func (self *Helper) Init() *CDP

func (*Helper) InnerHTML

func (self *Helper) InnerHTML(sel string, buf *string, opts ...chromedp.QueryOption) error

func (*Helper) WithCookie

func (self *Helper) WithCookie(cookie map[string]interface{}) error

func (*Helper) WithCookies

func (self *Helper) WithCookies(cookies []map[string]interface{}) error

func (*Helper) WithDebugLogger

func (self *Helper) WithDebugLogger(f func(string, ...interface{})) *Helper

func (*Helper) WithErrorLogger

func (self *Helper) WithErrorLogger(f func(string, ...interface{})) *Helper

func (*Helper) WithInfoLogger

func (self *Helper) WithInfoLogger(f func(string, ...interface{})) *Helper

Jump to

Keyboard shortcuts

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