cuto

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: MIT Imports: 20 Imported by: 1

README

Cuto

GO语言跨平台驱动chrome内核浏览器,实现自动化操作。

Require

  • Go >= 1.11
  • chromium >= 69

支持

  • Mac Os
  • Linux
  • Windows

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Browser

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

func NewBrowser

func NewBrowser(options ...Option) (*Browser, error)

NewBrowser chrome client

func (*Browser) Close

func (b *Browser) Close() error

Close chrome

func (*Browser) Find

func (b *Browser) Find(kw string) (*Tab, error)

Catch tab

func (*Browser) Open

func (b *Browser) Open(url string) (*Tab, error)

Open new tab

type Channel

type Channel struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

type Error

type Error struct {
	Id    int
	Error struct {
		Code    int
		Data    string
		Message string
	}
}

type Event

type Event struct {
	Method string
	Params interface{}
}

type Option

type Option func(b *Browser)

func Binary

func Binary(bin string) Option

func DataDir

func DataDir(dir string) Option

func Debug

func Debug() Option

func Headless

func Headless() Option

func RemoteAddr

func RemoteAddr(addr string) Option

func Timeout

func Timeout(d time.Duration) Option

type Return

type Return struct {
	Id     int
	Result interface{}
}

type Tab

type Tab struct {
	Id                   string `json:"id"`
	Url                  string `json:"url"`
	Type                 string `json:"type"`
	Title                string `json:"title"`
	DevtoolsFrontendUrl  string `json:"devtoolsFrontendUrl"`
	WebSocketDebuggerUrl string `json:"webSocketDebuggerUrl"`

	Channel Channel `json:"-"`
	// contains filtered or unexported fields
}

func (*Tab) Capture

func (tab *Tab) Capture(filename string, quality int, viewport page.Viewport) error

页面截图

func (*Tab) Check

func (tab *Tab) Check(selector string, checked bool) error

选择

func (*Tab) Click

func (tab *Tab) Click(selector string) error

元素点击

func (*Tab) Close

func (tab *Tab) Close() error

关闭标签

func (*Tab) DOMCapture

func (tab *Tab) DOMCapture(filename string, quality int, selector string) error

元素截图

func (*Tab) FullCapture

func (tab *Tab) FullCapture(filename string, quality int) error

获取整个页面的截图

func (*Tab) GetResult

func (tab *Tab) GetResult(returns interface{}) error

func (*Tab) Input

func (tab *Tab) Input(selector, v string) error

输入值

func (*Tab) Js

func (tab *Tab) Js(js string, timeout runtime.TimeDelta) (object runtime.RemoteObject, err error)

运行Javascript

func (*Tab) Jump

func (tab *Tab) Jump(url string) error

跳转地址

func (*Tab) PollEvent

func (tab *Tab) PollEvent(method string, params interface{}) error

func (*Tab) Query

func (tab *Tab) Query(selector string) ([]*dom.NodeId, error)

查询节点

func (*Tab) Refresh

func (tab *Tab) Refresh() error

页面刷新

func (*Tab) Select

func (tab *Tab) Select(selector, v string) error

下拉框

func (*Tab) Send

func (tab *Tab) Send(method string, params interface{}) error

发起命令

func (*Tab) Text

func (tab *Tab) Text(selector string) string

获取文本信息

func (*Tab) Value

func (tab *Tab) Value(selector string) string

元素值

func (*Tab) Wait

func (tab *Tab) Wait() error

等待页面加载完成

Jump to

Keyboard shortcuts

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