phantomgo

package
v0.0.0-...-f3abbe6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DIY_JS_FILE_NAME = "diy_jsfile_to_phantom"
View Source
const GET_JS_FILE_NAME = "get_jsfile_to_phantom"

javascript temp file name

View Source
const POST_JS_FILE_NAME = "post_jsfile_to_phantom"

Variables

View Source
var GOPATH = os.Getenv("GOPATH")

Functions

This section is empty.

Types

type Param

type Param struct {
	Method        string
	Url           string
	Header        http.Header
	PostBody      string
	RedirectTimes int //request redirect times allow 重定向次数
	DialTimeout   time.Duration
	ConnTimeout   time.Duration
	RetryPause    time.Duration //if request failed,retry time
	TryTimes      int           //if request failed,retry times
	UsePhantomJS  bool
}

供外部调用 external interface

func (*Param) GetConnTimeout

func (self *Param) GetConnTimeout() time.Duration

func (*Param) GetDialTimeout

func (self *Param) GetDialTimeout() time.Duration

func (*Param) GetHeader

func (self *Param) GetHeader() http.Header

func (*Param) GetMethod

func (self *Param) GetMethod() string

func (*Param) GetPostBody

func (self *Param) GetPostBody() string

func (*Param) GetRedirectTimes

func (self *Param) GetRedirectTimes() int

func (*Param) GetRetryPause

func (self *Param) GetRetryPause() time.Duration

func (*Param) GetTryTimes

func (self *Param) GetTryTimes() int

func (*Param) GetUrl

func (self *Param) GetUrl() string

func (*Param) GetusePhantomJS

func (self *Param) GetusePhantomJS() bool

type Phantom

type Phantom struct {
	WebrowseParam
	// contains filtered or unexported fields
}

func (*Phantom) CreatJsFile

func (self *Phantom) CreatJsFile(jsfile string)

创建js临时文件 creat temp javascript file

func (*Phantom) DestroyJsFile

func (self *Phantom) DestroyJsFile(filename string)

销毁js临时文件

func (*Phantom) Download

func (self *Phantom) Download(req Request) (resp *http.Response, err error)

func (*Phantom) Exec

func (self *Phantom) Exec(js string, args ...string) (stdout io.ReadCloser, err error)

exec javascript

func (*Phantom) Exist

func (self *Phantom) Exist(filename string) bool

判断js临时文件是否存在 Is js file exist

func (*Phantom) Open

func (self *Phantom) Open(openArgs ...string) (stdout io.ReadCloser, err error)

open the url address

func (*Phantom) SetPageEncode

func (self *Phantom) SetPageEncode(pageEncode string)

set web page decode for example [utf-8|gbk]

func (*Phantom) SetPhantomjsPath

func (self *Phantom) SetPhantomjsPath(name string, filepath string)

动态修改执行文件的Phantomjs.exe路径 set the phantomjs exec file

func (*Phantom) SetProxy

func (self *Phantom) SetProxy(proxy string)

SetProxy for example address:port

func (*Phantom) SetProxyAuth

func (self *Phantom) SetProxyAuth(proxyAuth string)

SetProxyAuth for example username:password

func (*Phantom) SetProxyType

func (self *Phantom) SetProxyType(proxyType string)

SetProxyType for example [http|socks5|none]

func (*Phantom) SetUserAgent

func (self *Phantom) SetUserAgent(userAgent string)

SetUserAgent for example [chrome,firefox,IE..]

type Phantomer

type Phantomer interface {
	SetUserAgent(string)
	SetProxy(string)
	SetProxyType(string)
	SetProxyAuth(string)
	SetPhantomjsPath(string, string)
	Download(Request) (*http.Response, error)
	Exec(string, ...string) (io.ReadCloser, error)
}

func NewPhantom

func NewPhantom() Phantomer

type Request

type Request interface {
	GetMethod() string
	GetUrl() string
	GetHeader() http.Header
	GetPostBody() string
	GetRedirectTimes() int
	GetDialTimeout() time.Duration
	GetConnTimeout() time.Duration
	GetRetryPause() time.Duration
	GetTryTimes() int
	GetusePhantomJS() bool
}

供内部调用 interior interface

type WebrowseParam

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

web browse param

Jump to

Keyboard shortcuts

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