Documentation ¶
Index ¶
- Variables
- func ModifyLink(url string) string
- type Client
- type DelayLimiterOpinion
- type FilterLimiterOpinion
- type FormField
- type FormFile
- type Handler
- type LimitRuleAllow
- type LimiterMatcher
- type Middleware
- func WithCache(ca *cache.Cache) Middleware
- func WithDebug() Middleware
- func WithDelayLimiter(eachSite bool, opts ...*DelayLimiterOpinion) Middleware
- func WithFilterLimiter(noneMatchAllow bool, opts ...*FilterLimiterOpinion) Middleware
- func WithParallelismLimiter(eachSite bool, opts ...*ParallelismLimiterOpinion) Middleware
- func WithProxy(p ...string) Middleware
- func WithRandomUA() Middleware
- func WithRateLimiter(eachSite bool, opts ...*RateLimiterOpinion) Middleware
- func WithRefererFiller() Middleware
- func WithRetry(maxTimes int, isRespOk func(*Response) bool) Middleware
- type ParallelismLimiterOpinion
- type RateLimiterOpinion
- type ReqError
- type Request
- func Connect(urladdr string) *Request
- func Delete(urladdr string) *Request
- func Get(urladdr string) *Request
- func Head(urladdr string) *Request
- func NewRequest(method, urladdr string) *Request
- func Options(urladdr string) *Request
- func Patch(urladdr string) *Request
- func Post(urladdr string) *Request
- func Put(urladdr string) *Request
- func Trace(urladdr string) *Request
- func (s *Request) AddCookie(c *http.Cookie) *Request
- func (s *Request) AddCookies(cs ...*http.Cookie) *Request
- func (s *Request) AddHeader(key, value string) *Request
- func (s *Request) AddHeaders(v map[string]string) *Request
- func (s *Request) AddParam(k, v string) *Request
- func (s *Request) AddParams(v map[string]string) *Request
- func (s *Request) DisableRedirect() *Request
- func (s *Request) Do() *Response
- func (s *Request) SetBasicAuth(username, password string) *Request
- func (s *Request) SetBody(b io.Reader) *Request
- func (s *Request) SetCallback(fn func(resp *Response) *Response) *Request
- func (s *Request) SetCheckRedirect(fn func(req *http.Request, via []*http.Request) error) *Request
- func (s *Request) SetClient(c *Client) *Request
- func (s *Request) SetDebug(d bool) *Request
- func (s *Request) SetFormBody(v map[string]string) *Request
- func (s *Request) SetJsonBody(v interface{}) *Request
- func (s *Request) SetMultipartBody(data ...interface{}) *Request
- func (s *Request) SetProxy(urladdr string) *Request
- func (s *Request) SetRawBody(b []byte) *Request
- func (s *Request) SetTimeout(t time.Duration) *Request
- func (s *Request) SetUA(ua string) *Request
- func (s *Request) String() string
- type Response
- func (s *Response) BindJSON(i interface{}) error
- func (s *Response) BindXML(i interface{}) error
- func (s *Response) DecodeAndParse() error
- func (s *Response) Error() error
- func (s *Response) HTML() (*goquery.Document, error)
- func (s *Response) IsHTML() bool
- func (s *Response) IsJSON() bool
- func (s *Response) JSON() (gjson.Result, error)
- func (s *Response) Resp() (*Response, error)
- func (s *Response) Txt() (string, error)
- func (s *Response) XML() (*xmlpath.Node, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var Debug = false //TODO
View Source
var DefaultClient = NewClient()
View Source
var ReqRejectedErr = errors.New("request is rejected")
Functions ¶
func ModifyLink ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(m ...Middleware) *Client
func (*Client) Use ¶
func (s *Client) Use(m ...Middleware) *Client
type DelayLimiterOpinion ¶
type DelayLimiterOpinion struct { LimiterMatcher Delay time.Duration RandomDelay time.Duration // contains filtered or unexported fields }
type FilterLimiterOpinion ¶
type FilterLimiterOpinion struct { LimiterMatcher Allow bool }
type LimitRuleAllow ¶
type LimitRuleAllow uint8
const ( NotSet LimitRuleAllow = iota Allow Disallow )
type LimiterMatcher ¶
type LimiterMatcher struct {
Regexp, Glob string
// contains filtered or unexported fields
}
func (*LimiterMatcher) Compile ¶
func (s *LimiterMatcher) Compile()
type Middleware ¶
func WithCache ¶
func WithCache(ca *cache.Cache) Middleware
func WithDebug ¶
func WithDebug() Middleware
func WithDelayLimiter ¶
func WithDelayLimiter(eachSite bool, opts ...*DelayLimiterOpinion) Middleware
func WithFilterLimiter ¶
func WithFilterLimiter(noneMatchAllow bool, opts ...*FilterLimiterOpinion) Middleware
func WithParallelismLimiter ¶
func WithParallelismLimiter(eachSite bool, opts ...*ParallelismLimiterOpinion) Middleware
func WithProxy ¶
func WithProxy(p ...string) Middleware
func WithRandomUA ¶
func WithRandomUA() Middleware
func WithRateLimiter ¶
func WithRateLimiter(eachSite bool, opts ...*RateLimiterOpinion) Middleware
func WithRefererFiller ¶
func WithRefererFiller() Middleware
type ParallelismLimiterOpinion ¶
type ParallelismLimiterOpinion struct { LimiterMatcher Parallelism int64 // contains filtered or unexported fields }
type RateLimiterOpinion ¶
type RateLimiterOpinion struct { LimiterMatcher Rate int64 // contains filtered or unexported fields }
type Request ¶
type Request struct { *http.Request // ProxyURL is the proxy address that handles the request ProxyURL string RespEncode string Writer io.Writer Debug bool Err error // contains filtered or unexported fields }
Request is a object of HTTP request
func NewRequest ¶
func (*Request) AddCookies ¶
AddCookies adds some cookie to the request at once.
func (*Request) AddHeader ¶
SetHeader sets the header entries associated with key to the single element value.
func (*Request) DisableRedirect ¶
func (*Request) SetBasicAuth ¶
func (*Request) SetCallback ¶
func (*Request) SetCheckRedirect ¶
func (*Request) SetJsonBody ¶
func (*Request) SetMultipartBody ¶
func (*Request) SetRawBody ¶
type Response ¶
type Response struct { *http.Response // Body is the content of the Response Body []byte NoDecodeBody []byte // Text is the content of the Response parsed as string Text string // Request is the Req object from goribot of the response.Tip: there is another Request attr come from *http.Response Req *Request Err error }
Response is a object of HTTP response
func (*Response) DecodeAndParse ¶
DecodeAndParas decodes the body to text and try to parse it to html or json.
Click to show internal directories.
Click to hide internal directories.