Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

http

v0.0.10
apigo.cc/gojs/http

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

156 matches

Top ↑

Variables

KeyMap

var KeyMap = map[string]input.Key{
	"Escape":         input.Escape,
	"Esc":            input.Escape,
	"F1":             input.F1,
	"F2":             input.F2,
	"F3":             input.F3,
	"F4":             input.F4,
	"F5":             input.F5,
	"F6":             input.F6,
	"F7":             input.F7,
	"F8":             input.F8,
	"F9":             input.F9,
	"F10":            input.F10,
	"F11":            input.F11,
	"F12":            input.F12,
	"Backquote":      input.Backquote,
	"1":              input.Digit1,
	"2":              input.Digit2,
	"3":              input.Digit3,
	"4":              input.Digit4,
	"5":              input.Digit5,
	"6":              input.Digit6,
	"7":              input.Digit7,
	"8":              input.Digit8,
	"9":              input.Digit9,
	"0":              input.Digit0,
	"Digit1":         input.Digit1,
	"Digit2":         input.Digit2,
	"Digit3":         input.Digit3,
	"Digit4":         input.Digit4,
	"Digit5":         input.Digit5,
	"Digit6":         input.Digit6,
	"Digit7":         input.Digit7,
	"Digit8":         input.Digit8,
	"Digit9":         input.Digit9,
	"Digit0":         input.Digit0,
	"Minus":          input.Minus,
	"Equal":          input.Equal,
	"Backslash":      input.Backslash,
	"Backspace":      input.Backspace,
	"Tab":            input.Tab,
	"KeyQ":           input.KeyQ,
	"Q":              input.KeyQ,
	"KeyW":           input.KeyW,
	"W":              input.KeyW,
	"KeyE":           input.KeyE,
	"E":              input.KeyE,
	"KeyR":           input.KeyR,
	"R":              input.KeyR,
	"KeyT":           input.KeyT,
	"T":              input.KeyT,
	"KeyY":           input.KeyY,
	"Y":              input.KeyY,
	"KeyU":           input.KeyU,
	"U":              input.KeyU,
	"KeyI":           input.KeyI,
	"I":              input.KeyI,
	"KeyO":           input.KeyO,
	"O":              input.KeyO,
	"KeyP":           input.KeyP,
	"P":              input.KeyP,
	"BracketLeft":    input.BracketLeft,
	"BracketRight":   input.BracketRight,
	"CapsLock":       input.CapsLock,
	"KeyA":           input.KeyA,
	"A":              input.KeyA,
	"KeyS":           input.KeyS,
	"S":              input.KeyS,
	"KeyD":           input.KeyD,
	"D":              input.KeyD,
	"KeyF":           input.KeyF,
	"F":              input.KeyF,
	"KeyG":           input.KeyG,
	"G":              input.KeyG,
	"KeyH":           input.KeyH,
	"H":              input.KeyH,
	"KeyJ":           input.KeyJ,
	"J":              input.KeyJ,
	"KeyK":           input.KeyK,
	"K":              input.KeyK,
	"KeyL":           input.KeyL,
	"L":              input.KeyL,
	"Semicolon":      input.Semicolon,
	"Quote":          input.Quote,
	"Enter":          input.Enter,
	"ShiftLeft":      input.ShiftLeft,
	"KeyZ":           input.KeyZ,
	"Z":              input.KeyZ,
	"KeyX":           input.KeyX,
	"X":              input.KeyX,
	"KeyC":           input.KeyC,
	"C":              input.KeyC,
	"KeyV":           input.KeyV,
	"V":              input.KeyV,
	"KeyB":           input.KeyB,
	"B":              input.KeyB,
	"KeyN":           input.KeyN,
	"N":              input.KeyN,
	"KeyM":           input.KeyM,
	"M":              input.KeyM,
	"Comma":          input.Comma,
	"Period":         input.Period,
	"Slash":          input.Slash,
	"ShiftRight":     input.ShiftRight,
	"ControlLeft":    input.ControlLeft,
	"MetaLeft":       input.MetaLeft,
	"AltLeft":        input.AltLeft,
	"Space":          input.Space,
	" ":              input.Space,
	"AltRight":       input.AltRight,
	"AltGraph":       input.AltGraph,
	"MetaRight":      input.MetaRight,
	"ContextMenu":    input.ContextMenu,
	"ControlRight":   input.ControlRight,
	"PrintScreen":    input.PrintScreen,
	"ScrollLock":     input.ScrollLock,
	"Pause":          input.Pause,
	"PageUp":         input.PageUp,
	"PageDown":       input.PageDown,
	"Insert":         input.Insert,
	"Delete":         input.Delete,
	"Home":           input.Home,
	"End":            input.End,
	"ArrowLeft":      input.ArrowLeft,
	"ArrowUp":        input.ArrowUp,
	"ArrowRight":     input.ArrowRight,
	"ArrowDown":      input.ArrowDown,
	"Left":           input.ArrowLeft,
	"Up":             input.ArrowUp,
	"Right":          input.ArrowRight,
	"Down":           input.ArrowDown,
	"NumLock":        input.NumLock,
	"NumpadDivide":   input.NumpadDivide,
	"NumpadMultiply": input.NumpadMultiply,
	"NumpadSubtract": input.NumpadSubtract,
	"Numpad7":        input.Numpad7,
	"Numpad8":        input.Numpad8,
	"Numpad9":        input.Numpad9,
	"Numpad4":        input.Numpad4,
	"Numpad5":        input.Numpad5,
	"Numpad6":        input.Numpad6,
	"NumpadAdd":      input.NumpadAdd,
	"Numpad1":        input.Numpad1,
	"Numpad2":        input.Numpad2,
	"Numpad3":        input.Numpad3,
	"Numpad0":        input.Numpad0,
	"NumpadDecimal":  input.NumpadDecimal,
	"NumpadEnter":    input.NumpadEnter,
	"NumDivide":      input.NumpadDivide,
	"NumMultiply":    input.NumpadMultiply,
	"NumSubtract":    input.NumpadSubtract,
	"Num7":           input.Numpad7,
	"Num8":           input.Numpad8,
	"Num9":           input.Numpad9,
	"Num4":           input.Numpad4,
	"Num5":           input.Numpad5,
	"Num6":           input.Numpad6,
	"NumAdd":         input.NumpadAdd,
	"Num1":           input.Numpad1,
	"Num2":           input.Numpad2,
	"Num3":           input.Numpad3,
	"Num0":           input.Numpad0,
	"NumDecimal":     input.NumpadDecimal,
	"NumEnter":       input.NumpadEnter,
	"Ctrl":           input.ControlLeft,
	"Control":        input.ControlLeft,
	"Cmd":            input.MetaLeft,
	"Windows":        input.MetaLeft,
	"Meta":           input.MetaLeft,
	"Win":            input.MetaLeft,
	"Option":         input.AltLeft,
	"Alt":            input.AltLeft,
	",":              input.Comma,
	".":              input.Period,
	"/":              input.Slash,
	";":              input.Semicolon,
	"'":              input.Quote,
	"[":              input.BracketLeft,
	"]":              input.BracketRight,
	"\\":             input.Backslash,
	"-":              input.Minus,
	"=":              input.Equal,
	"`":              input.Backquote,
}

Functions

CloseAllChrome

func CloseAllChrome(vm *goja.Runtime)

Types

Chrome

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

StartChrome

func StartChrome(opt *ChromeOption, vm *goja.Runtime) (*Chrome, error)

Chrome.Close

func (ch *Chrome) Close(vm *goja.Runtime)

Chrome.Info

func (ch *Chrome) Info(showWindow *bool, vm *goja.Runtime) (ChromeInfo, error)

Chrome.Open

func (ch *Chrome) Open(url string) (*Page, error)

ChromeInfo

type ChromeInfo struct {
	ProtocolVersion string
	Product         string
	Revision        string
	UserAgent       string
	JsVersion       string
	ChromeURL       string
	ChromePath      string
}

ChromeOption

type ChromeOption struct {
	ChromeURL            string
	ChromePath           string
	ChromeDownloadMirror string
	ChromeDownloadPath   string
	ChromeOption         []string
	ShowWindow           bool
	HttpProxy            string
	UserAgent            string
}

Element

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

Element.AddClass

func (el *Element) AddClass(className string) error

Element.Check

func (el *Element) Check() error

Check 勾选复选框

Element.Children

func (el *Element) Children() ([]*Element, error)

Children 获取所有直接子元素

Element.Click

func (el *Element) Click() error

Element.Find

func (el *Element) Find(selector string) (*Element, error)

Find 在当前元素下查找匹配选择器的第一个元素

Element.FindAll

func (el *Element) FindAll(selector string) ([]*Element, error)

FindAll 在当前元素下查找所有匹配选择器的元素

Element.FindAllX

func (el *Element) FindAllX(selector string) ([]*Element, error)

FindAll 在当前元素下查找所有匹配选择器的元素

Element.FindChild

func (el *Element) FindChild(selector string) (*Element, error)

Find 在当前元素下查找匹配选择器的第一个元素

Element.FindChildN

func (el *Element) FindChildN(selector string) *Element

Element.FindChildren

func (el *Element) FindChildren(selector string) ([]*Element, error)

FindAll 在当前元素下查找所有匹配选择器的元素

Element.FindN

func (el *Element) FindN(selector string) *Element

Element.FindParent

func (el *Element) FindParent(selector string) (*Element, error)

FindParent 向上查找匹配选择器的父元素

Element.FindParentN

func (el *Element) FindParentN(selector string) *Element

Element.FindParentX

func (el *Element) FindParentX(selector string) (*Element, error)

FindParent 向上查找匹配选择器的父元素

Element.FindParentXN

func (el *Element) FindParentXN(selector string) *Element

Element.FindX

func (el *Element) FindX(selector string) (*Element, error)

Find 在当前元素下查找匹配选择器的第一个元素

Element.FindXN

func (el *Element) FindXN(selector string) *Element

Element.Focus

func (el *Element) Focus() error

Element.GetAttribute

func (el *Element) GetAttribute(name string) (*string, error)

GetAttribute 获取元素属性值 name: 属性名称 返回值: 属性值字符串,若不存在则返回空字符串

Element.GetBoundingRect

func (el *Element) GetBoundingRect() (*Rect, error)

Element.GetCenter

func (el *Element) GetCenter() (*Position, error)

Element.GetChecked

func (el *Element) GetChecked() ([]string, error)

GetSelectedValues 获取当前选中的值(单选返回字符串,多选返回切片)

Element.GetClass

func (el *Element) GetClass() ([]string, error)

Element.GetComputedStyle

func (el *Element) GetComputedStyle() (map[string]string, error)

GetComputedStyle 获取元素所有计算样式

Element.GetForm

func (el *Element) GetForm() (*Element, error)

GetForm 获取当前元素所属的表单

Element.GetFormData

func (el *Element) GetFormData() (map[string]string, error)

GetFormData 获取表单数据

Element.GetID

func (el *Element) GetID() (*string, error)

GetID 获取元素ID

Element.GetName

func (el *Element) GetName() (*string, error)

GetName 获取元素名称(如<input name="username">)

Element.GetOptions

func (el *Element) GetOptions() ([]map[string]string, error)

GetAllOptions 获取所有选项(值和文本)

Element.GetPosition

func (el *Element) GetPosition() (*Position, error)

GetPosition 获取元素位置(中心点)

Element.GetProperty

func (el *Element) GetProperty(name string) (interface{}, error)

GetProperty 获取 JavaScript 属性值 name: 属性名称 返回值: 属性值(interface{} 类型)

Element.GetStyle

func (el *Element) GetStyle(property string) (string, error)

GetStyle 获取指定CSS样式值

Element.GetType

func (el *Element) GetType() (*string, error)

GetType 获取元素类型(如"text"/"checkbox"等)

Element.GetValue

func (el *Element) GetValue() (string, error)

GetValue 获取表单元素的值

Element.HasAttribute

func (el *Element) HasAttribute(name string) (bool, error)

HasAttribute 检查属性是否存在

Element.HasProperty

func (el *Element) HasProperty(name string) (bool, error)

HasProperty 检查属性是否存在

Element.Hover

func (el *Element) Hover() error

Element.InnerHTML

func (el *Element) InnerHTML() (string, error)

Element.Input

func (el *Element) Input(text string) error

Element.IsChecked

func (el *Element) IsChecked() (bool, error)

IsChecked 获取复选框/单选框的选中状态

Element.IsDisabled

func (el *Element) IsDisabled() (bool, error)

IsDisabled 判断元素是否被禁用

Element.IsInteractable

func (el *Element) IsInteractable() (bool, error)

IsInteractable 元素是否可交互

Element.IsVisible

func (el *Element) IsVisible() (bool, error)

IsVisible 判断元素是否可见

Element.Key

func (el *Element) Key(keys ...string) error

Element.KeyPress

func (el *Element) KeyPress(keys ...string) error

元素级

Element.KeyRelease

func (el *Element) KeyRelease(keys ...string) error

Element.KeyType

func (el *Element) KeyType(keys ...string) error

Element.OuterHTML

func (el *Element) OuterHTML() (string, error)

Element.Parent

func (el *Element) Parent() (*Element, error)

Parent 获取直接父元素

Element.RadioGroupValue

func (el *Element) RadioGroupValue() (string, error)

RadioGroupValue 获取单选按钮组的当前值

Element.RemoveAttribute

func (el *Element) RemoveAttribute(name string) error

RemoveAttribute 移除元素属性 name: 要移除的属性名称

Element.RemoveClass

func (el *Element) RemoveClass(className string) error

Element.RemoveProperty

func (el *Element) RemoveProperty(name string) error

Element.ScrollIntoView

func (el *Element) ScrollIntoView() error

Element.Select

func (el *Element) Select(values ...string) error

Select 选择下拉框的选项(单选或多选)

Element.SelectByText

func (el *Element) SelectByText(text string) error

SelectByText 通过文本选择选项

Element.SelectByValue

func (el *Element) SelectByValue(value string) error

SelectByValue 通过值选择选项

Element.SetAttribute

func (el *Element) SetAttribute(name, value string) error

SetAttribute 设置元素属性值 name: 属性名称 value: 属性值

Element.SetChecked

func (el *Element) SetChecked(checked bool) error

SetChecked 设置复选框/单选框的选中状态

Element.SetInnerHTML

func (el *Element) SetInnerHTML(html string) error

Element.SetProperty

func (el *Element) SetProperty(name string, value interface{}) error

SetProperty 设置 JavaScript 属性 name: 属性名称 value: 属性值(可以是任意类型)

Element.SetRadioGroupValue

func (el *Element) SetRadioGroupValue(value string) error

SetRadioGroupValue 设置单选按钮组的值

Element.SetRadioValue

func (el *Element) SetRadioValue(value string) error

SetRadioValue 设置单选框值

Element.SetStyle

func (el *Element) SetStyle(property, value string) error

SetStyle 设置CSS样式

Element.SetText

func (el *Element) SetText(text string) error

Element.SetValue

func (el *Element) SetValue(value string) error

SetValue 设置表单元素的值(input/textarea)

Element.Submit

func (el *Element) Submit() error

Submit 提交表单(必须在FORM元素上调用)

Element.Text

func (el *Element) Text() (string, error)

Element.Uncheck

func (el *Element) Uncheck() error

Uncheck 取消勾选

Element.UploadFile

func (el *Element) UploadFile(filePaths []string) error

Element.WaitEnabled

func (el *Element) WaitEnabled() error

Element.WaitInvisible

func (el *Element) WaitInvisible() error

Element.WaitStable

func (el *Element) WaitStable(ms *int) error

Element.WaitVisible

func (el *Element) WaitVisible() error

Http

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

Http.Connect

func (hc *Http) Connect(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Http.Delete

func (hc *Http) Delete(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Http.Do

func (hc *Http) Do(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Http.Download

func (hc *Http) Download(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Http.Get

func (hc *Http) Get(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Http.Head

func (hc *Http) Head(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Http.Post

func (hc *Http) Post(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Http.Put

func (hc *Http) Put(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Http.Upload

func (hc *Http) Upload(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Page

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

Page.AccepDialog

func (pg *Page) AccepDialog() error

AutoAcceptAlerts 自动接受所有弹框

Page.Back

func (pg *Page) Back() error

Page.Close

func (pg *Page) Close() error

Page.DismissDialog

func (pg *Page) DismissDialog() error

AutoDismissAlerts 自动取消所有弹框

Page.Eval

func (pg *Page) Eval(js string) (interface{}, error)

Page.Find

func (pg *Page) Find(selector string) (*Element, error)

Page.FindAll

func (pg *Page) FindAll(selector string) ([]*Element, error)

Page.FindAllX

func (pg *Page) FindAllX(xpath string) ([]*Element, error)

FindsX 通过XPath查找多个元素

Page.FindN

func (pg *Page) FindN(selector string) *Element

Page.FindX

func (pg *Page) FindX(xpath string) (*Element, error)

FindX 通过XPath查找元素

Page.FindXN

func (pg *Page) FindXN(selector string) *Element

Page.Forward

func (pg *Page) Forward() error

Page.Frame

func (pg *Page) Frame(selector string) (*Page, error)

Frame 获取iframe内容

Page.GetCookies

func (pg *Page) GetCookies() (map[string]string, error)

Page.GetResContent

func (pg *Page) GetResContent(url string) ([]byte, error)

Page.GetResList

func (pg *Page) GetResList() ([]Resource, error)

Page.GetResListByMimeType

func (pg *Page) GetResListByMimeType(mimeType string) ([]Resource, error)

Page.GetResListByType

func (pg *Page) GetResListByType(resType string) ([]Resource, error)

Page.HandleDialog

func (pg *Page) HandleDialog(accept bool, promptText string) error

HandleDialog 设置弹框处理器 示例:pg.HandleDialog(true, "") 接受所有弹框

Page.Html

func (pg *Page) Html() (string, error)

Page.Key

func (pg *Page) Key(keys ...string) error

Page.KeyPress

func (pg *Page) KeyPress(keys ...string) error

Page.KeyRelease

func (pg *Page) KeyRelease(keys ...string) error

Page.KeyType

func (pg *Page) KeyType(keys ...string) error

Page.MouseClick

func (pg *Page) MouseClick() error

Page.MouseDown

func (pg *Page) MouseDown() error

Page.MouseMiddleClick

func (pg *Page) MouseMiddleClick() error

Page.MouseMoveTo

func (pg *Page) MouseMoveTo(x, y float64) error

Page.MouseRightClick

func (pg *Page) MouseRightClick() error

Page.MouseUp

func (pg *Page) MouseUp() error

Page.Navigate

func (pg *Page) Navigate(url string) error

Page.PDF

func (pg *Page) PDF() ([]byte, error)

PDF 生成页面PDF

Page.RandWait

func (pg *Page) RandWait(msMin int, msMax int)

RandWait 随机等待

Page.ResetTimeout

func (pg *Page) ResetTimeout()

Page.Screenshot

func (pg *Page) Screenshot() ([]byte, error)

Page.ScreenshotFullPage

func (pg *Page) ScreenshotFullPage() ([]byte, error)

Screenshot 截图

Page.ScrollTo

func (pg *Page) ScrollTo(x, y float64) error

ScrollTo 滚动到指定位置

Page.SetCookies

func (pg *Page) SetCookies(cookies map[string]string) error

Page.SetPhoneViewport

func (pg *Page) SetPhoneViewport(width, height int) error

Page.SetPrompt

func (pg *Page) SetPrompt(text string) error

Page.SetUserAgent

func (pg *Page) SetUserAgent(ua string) error

Page.SetUserAgentInfo

func (pg *Page) SetUserAgentInfo(ua string, platform string, acceptLanguage string) error

Page.SetViewport

func (pg *Page) SetViewport(width, height int) error

SetViewport 设置视口大小

Page.Title

func (pg *Page) Title() (string, error)

Page.Url

func (pg *Page) Url() (string, error)

Page.Wait

func (pg *Page) Wait(ms int, fn *func() bool)

Wait 等待回调函数函数返回true

Page.WaitIdle

func (pg *Page) WaitIdle(ms *int) error

WaitIdle 等待页面空闲(无网络请求和JS执行)

Page.WaitPageLoad

func (pg *Page) WaitPageLoad() error

WaitLoad 等待页面加载完成

Position

type Position struct {
	X float64
	Y float64
}

Rect

type Rect struct{ X, Y, Width, Height float64 }

Resource

type Resource struct {
	Url          string
	Type         string
	Size         int
	MimeType     string
	LastModified string
	Success      bool
}

WS

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

WS.Close

func (ws *WS) Close(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

WS.Ping

func (ws *WS) Ping(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

WS.PingCount

func (ws *WS) PingCount(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

WS.Read

func (ws *WS) Read(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

WS.Write

func (ws *WS) Write(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

WS.WriteMessage

func (ws *WS) WriteMessage(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Dependency graph