proxypool

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProxyPoolOptionCountry_domestic = "国内"
	ProxyPoolOptionCountry_foreign  = "国外"
)
View Source
const (
	DefaultMaxRetryTimes = 3
	DefaultHTTPTimeout   = time.Second * 5
	DefaultWaitInterval  = time.Second * 15
)

Variables

View Source
var (
	ErrFirewallDeny = errors.New("proxypool: Firewall denied access")
	ErrTimeout      = errors.New("proxypool: Connection timeout")
	ErrIllegalBody  = errors.New("proxypool: Body contains illegal substr")
	ErrIllegalURL   = errors.New("proxypool: URL contains illegal substr")
	ErrNotFound     = errors.New("proxypool: Not found a useful proxy url")
)
View Source
var (
	DistantFuture = time.Hour * 24 * 365 * 100
)

Functions

func IsConnectionErr

func IsConnectionErr(err error) bool

isConnectionErr

func IsTimeoutErr

func IsTimeoutErr(err error) bool

isTimeout

Types

type PostHandler

type PostHandler func(*http.Response, io.Reader) error

func WithBodyContains

func WithBodyContains(substr string) PostHandler

func WithURLContains

func WithURLContains(substr string) PostHandler

type PreHandler

type PreHandler func(*http.Request) error

type ProxyPool

type ProxyPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewPool

func NewPool(opt ProxyPoolOption) (*ProxyPool, error)

func (*ProxyPool) Close

func (p *ProxyPool) Close()

Close

func (*ProxyPool) Dirty

func (p *ProxyPool) Dirty(item *url.URL, wait time.Duration)

Dirty

func (*ProxyPool) Do

func (p *ProxyPool) Do(req *http.Request) (resp *http.Response, err error)

Do http.Do

func (*ProxyPool) NewClient

func (p *ProxyPool) NewClient() (cli *http.Client, purl *url.URL, err error)

ProxyClient

func (*ProxyPool) ProxyURL

func (p *ProxyPool) ProxyURL() (*url.URL, error)

ProxyURL

func (*ProxyPool) WithPostHandle

func (p *ProxyPool) WithPostHandle(hdls ...PostHandler) *ProxyPool

func (*ProxyPool) WithPreHandle

func (p *ProxyPool) WithPreHandle(hdls ...PreHandler) *ProxyPool

func (*ProxyPool) WithRetryTimes

func (p *ProxyPool) WithRetryTimes(times int) *ProxyPool

func (*ProxyPool) WithTimeout

func (p *ProxyPool) WithTimeout(timeout time.Duration) *ProxyPool

func (*ProxyPool) WithWaitInterval

func (p *ProxyPool) WithWaitInterval(interval time.Duration) *ProxyPool

type ProxyPoolOption

type ProxyPoolOption struct {
	PoolURL     string
	Transparent bool // 透明,否则高匿
	UseHttps    bool
	Count       int
	Country     string
	Area        string
}

func (*ProxyPoolOption) URL

func (opt *ProxyPoolOption) URL() *url.URL

Jump to

Keyboard shortcuts

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