spider

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadAll

func ReadAll(r io.Reader, size int) (buff []byte, err error)

Types

type ApiSpider

type ApiSpider struct {
	Jar http.CookieJar
	// contains filtered or unexported fields
}

func NewApiSpider

func NewApiSpider(size int) *ApiSpider

请求数据最大size限制

func (*ApiSpider) Do

func (a *ApiSpider) Do(request Request) (Response, error)

type Buffer

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

先看一下Buffer的定义,有帮助下面理解

func (*Buffer) Read

func (b *Buffer) Read(p []byte) (n int, err error)

func (*Buffer) ReadFrom

func (b *Buffer) ReadFrom(r io.Reader, size int) (n int64, err error)

func (*Buffer) Reset

func (b *Buffer) Reset()

type CookieCallBack added in v0.3.3

type CookieCallBack func() []*http.Cookie

type DhtmlSpider

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

func NewDhtmlSpider

func NewDhtmlSpider() *DhtmlSpider

func (*DhtmlSpider) Do

func (d *DhtmlSpider) Do(request Request) (Response, error)

type FileSpider

type FileSpider struct {
	Jar http.CookieJar
	// contains filtered or unexported fields
}

func NewFileSpider

func NewFileSpider(size int) *FileSpider

请求数据最大size限制

func (*FileSpider) Do

func (f *FileSpider) Do(request Request) (Response, error)

type ProxyCallBack

type ProxyCallBack func() string

type Request

type Request struct {
	Url                 string
	Method              string
	Param               string
	Headers             map[string]string
	Timeout             time.Duration
	Retry               int
	ProxyCallBack       ProxyCallBack
	SocketProxyCallBack SocketProxyCallBack
	CookieCallBack      CookieCallBack
}

type Response

type Response struct {
	RedirectUrl string
	SpiderType  SpiderType
	// contains filtered or unexported fields
}

func (*Response) GetBytes

func (r *Response) GetBytes() []byte

func (*Response) GetCharset

func (r *Response) GetCharset() string

func (*Response) GetContent

func (r *Response) GetContent() string

type ShtmlSpider

type ShtmlSpider struct {
	Jar http.CookieJar
	// contains filtered or unexported fields
}

func NewShtmlSpider

func NewShtmlSpider(size int) *ShtmlSpider

请求数据最大size限制

func (*ShtmlSpider) Do

func (s *ShtmlSpider) Do(request Request) (Response, error)

type SocketProxyCallBack added in v0.2.4

type SocketProxyCallBack func() (string, string, string)

type Spider

type Spider interface {
	Do(request Request) (Response, error)
}

type SpiderType

type SpiderType int
const (
	Shtml SpiderType = iota + 1
	Dhtml
	File
	Api
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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