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) WithOtherArgs(args []string) *BrowserInfo
- func (b *BrowserInfo) WithPort(port uint) *BrowserInfo
- func (b *BrowserInfo) WithUrl(url string) *BrowserInfo
- func (b *BrowserInfo) WithUserDataDir(dir 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 ¶
CookieConverter []*network.Cookie转为[]*http.Cookie
func GetCookies ¶
GetCookies 获取特定域名的Cookies
func HeaderConverter ¶
func HeaderConverter(header network.Headers) []*fetch.HeaderEntry
HeaderConverter network.Headers转为[]*fetch.HeaderEntry
func HeaderFromMap ¶
HeaderFromMap map[string]string转为network.Headers
Types ¶
type BrowserInfo ¶
type BrowserInfo struct {
// contains filtered or unexported fields
}
BrowserInfo 浏览器程序信息
func (*BrowserInfo) WithHeadless ¶
func (b *BrowserInfo) WithHeadless(headless bool) *BrowserInfo
WithHeadless 设置是否隐藏浏览器窗口, 默认为false
func (*BrowserInfo) WithName ¶
func (b *BrowserInfo) WithName(name string) *BrowserInfo
WithName 设置浏览器名称, 默认为chrome.exe
func (*BrowserInfo) WithOtherArgs ¶
func (b *BrowserInfo) WithOtherArgs(args []string) *BrowserInfo
WithOtherArgs 设置其他浏览器启动参数
func (*BrowserInfo) WithPort ¶
func (b *BrowserInfo) WithPort(port uint) *BrowserInfo
WithPort 设置浏览器CDP端口, 默认为9222
func (*BrowserInfo) WithUrl ¶
func (b *BrowserInfo) WithUrl(url string) *BrowserInfo
WithUrl 设置浏览器启动地址, 默认为$ProgramFiles (x86)\\Google\\Chrome\\Application\\chrome.exe
func (*BrowserInfo) WithUserDataDir ¶
func (b *BrowserInfo) WithUserDataDir(dir string) *BrowserInfo
WithUserDataDir 浏览器数据目录
func (*BrowserInfo) WithWindowHeight ¶
func (b *BrowserInfo) WithWindowHeight(height uint) *BrowserInfo
WithWindowHeight 设置浏览器窗口默认高度, 默认为0
func (*BrowserInfo) WithWindowWidth ¶
func (b *BrowserInfo) WithWindowWidth(width uint) *BrowserInfo
WithWindowWidth 设置浏览器窗口默认宽度, 默认为0,
type RequestMethod ¶
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" )
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 ¶
func (t *Tag) GetRequestTask(requestId string) *RequestTask
GetRequestTask 获取请求任务,可为nil
func (*Tag) RangeRequestTask ¶
func (t *Tag) RangeRequestTask(f func(key string, rt *RequestTask) bool)
RangeRequestTask 遍历请求任务
func (*Tag) WaitRequestTaskFinish ¶
func (t *Tag) WaitRequestTaskFinish(requestIdPts ...*string) chromedp.ActionFunc
WaitRequestTaskFinish 等待请求任务完成(不计算请求超时),requestIdPts为requestId的指针地址
Click to show internal directories.
Click to hide internal directories.