Documentation ¶
Index ¶
- func CookieConverter(cookies []*network.Cookie) []*http.Cookie
- func GetCookies(ctx context.Context, domain string) ([]*http.Cookie, error)
- func GetPostData(r *network.Request) string
- func HeaderConverter(header network.Headers) []*fetch.HeaderEntry
- func HeaderFromMap(header map[string]string) network.Headers
- func Request(method RequestMethod, urlStr, params string, headers map[string]string, ...) (string, error)
- func RequestRetry(retryCount int, method RequestMethod, urlStr, params string, ...) (string, error)
- type BrowserInfo
- func (b *BrowserInfo) WithHeadless(headless bool) *BrowserInfo
- func (b *BrowserInfo) WithName(name string) *BrowserInfo
- func (b *BrowserInfo) WithPort(port uint) *BrowserInfo
- func (b *BrowserInfo) WithUrl(url string) *BrowserInfo
- func (b *BrowserInfo) WithWindowHeight(height uint) *BrowserInfo
- func (b *BrowserInfo) WithWindowWidth(width uint) *BrowserInfo
- type RequestMethod
- type RequestTask
- type Tag
- func (t *Tag) Cancel()
- func (t *Tag) GetRequestTask(requestId string) *RequestTask
- func (t *Tag) RangeRequestTask(f func(key string, rt *RequestTask) bool)
- func (t *Tag) Run(actions ...chromedp.Action) error
- func (t *Tag) RunMain(actions ...chromedp.Action) error
- func (t *Tag) WaitRequestTaskFinish(requestIdPts ...*string) chromedp.ActionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CookieConverter ¶ added in v1.0.4
CookieConverter []*network.Cookie转为[]*http.Cookie
func GetCookies ¶ added in v1.0.5
GetCookies 获取特定域名的Cookies
func GetPostData ¶ added in v1.0.9
GetPostData 获取postData
func HeaderConverter ¶
func HeaderConverter(header network.Headers) []*fetch.HeaderEntry
HeaderConverter network.Headers转为[]*fetch.HeaderEntry
func HeaderFromMap ¶ added in v1.0.5
HeaderFromMap map[string]string转为network.Headers
Types ¶
type BrowserInfo ¶ added in v1.0.3
type BrowserInfo struct {
// contains filtered or unexported fields
}
BrowserInfo 浏览器程序信息
func GetBrowserInfo ¶ added in v1.0.3
func GetBrowserInfo() *BrowserInfo
GetBrowserInfo 线程安全的获取浏览器程序信息单例
func (*BrowserInfo) WithHeadless ¶ added in v1.0.3
func (b *BrowserInfo) WithHeadless(headless bool) *BrowserInfo
WithHeadless 设置是否隐藏浏览器窗口, 默认为false
func (*BrowserInfo) WithName ¶ added in v1.0.3
func (b *BrowserInfo) WithName(name string) *BrowserInfo
WithName 设置浏览器名称, 默认为chrome.exe
func (*BrowserInfo) WithPort ¶ added in v1.0.3
func (b *BrowserInfo) WithPort(port uint) *BrowserInfo
WithPort 设置浏览器CDP端口, 默认为9222
func (*BrowserInfo) WithUrl ¶ added in v1.0.3
func (b *BrowserInfo) WithUrl(url string) *BrowserInfo
WithUrl 设置浏览器启动地址, 默认为$ProgramFiles (x86)\\Google\\Chrome\\Application\\chrome.exe
func (*BrowserInfo) WithWindowHeight ¶ added in v1.0.3
func (b *BrowserInfo) WithWindowHeight(height uint) *BrowserInfo
WithWindowHeight 设置浏览器窗口默认高度, 默认为0
func (*BrowserInfo) WithWindowWidth ¶ added in v1.0.3
func (b *BrowserInfo) WithWindowWidth(width uint) *BrowserInfo
WithWindowWidth 设置浏览器窗口默认宽度, 默认为0,
type RequestMethod ¶ added in v1.0.5
type RequestMethod string
const ( RequestMethodGet RequestMethod = "GET" RequestMethodPost RequestMethod = "POST" RequestMethodPut RequestMethod = "PUT" RequestMethodDelete RequestMethod = "DELETE" RequestMethodHead RequestMethod = "HEAD" RequestMethodOptions RequestMethod = "OPTIONS" RequestMethodTrace RequestMethod = "TRACE" RequestMethodConnect RequestMethod = "CONNECT" )
func (RequestMethod) HasBody ¶ added in v1.0.5
func (rm RequestMethod) HasBody() bool
HasBody 是否有body
type RequestTask ¶
type RequestTask struct { RequestId string //请求ID DocumentUrl string //文档地址 Request *network.Request //请求 RequestStartTime time.Time //请求时间 Type network.ResourceType //类型 IsFinished bool //是否已经完成 Response *network.Response //响应 ResponseBody string //响应体 ErrorText string //错误原因 HasRewrite bool //是否修改过 RewriteParams *fetch.ContinueRequestParams //重写参数 }
type Tag ¶
type Tag struct { IsWaitCurrentRequestTasksFinished bool //是否等待当前所有的请求任务完成(或超时), 默认为true RequestTimeout time.Duration //请求超时时间,默认1min RequestPausedCallback func(rp *fetch.EventRequestPaused) *fetch.ContinueRequestParams RequestTaskValidTypesMap map[network.ResourceType]bool // 需要保存的请求任务类型,如果为空,则全部保存 // contains filtered or unexported fields }
Tag 浏览器标签
func (*Tag) GetRequestTask ¶ added in v1.0.2
func (t *Tag) GetRequestTask(requestId string) *RequestTask
GetRequestTask 获取请求任务,可为nil
func (*Tag) RangeRequestTask ¶ added in v1.0.1
func (t *Tag) RangeRequestTask(f func(key string, rt *RequestTask) bool)
RangeRequestTask 遍历请求任务
func (*Tag) WaitRequestTaskFinish ¶ added in v1.0.2
func (t *Tag) WaitRequestTaskFinish(requestIdPts ...*string) chromedp.ActionFunc
WaitRequestTaskFinish 等待请求任务完成(不计算请求超时),requestIdPts为requestId的指针地址
Click to show internal directories.
Click to hide internal directories.