Documentation
¶
Index ¶
- Constants
- func FormInput(form url.Values) (io.Reader, string)
- func JSONInput(input interface{}) (io.Reader, string)
- func Sleep(ctx context.Context, sleep time.Duration) error
- func XMLInput(xmlObj interface{}) (io.Reader, string)
- type ClientOption
- type ClientOptionFunc
- type ClientOptions
- type Crawl
- func (c *Crawl) ClientOpt(options ...ClientOption) *Crawl
- func (c *Crawl) Enqueue() *Crawler
- func (c *Crawl) EnqueueTo(crawler *Crawler) *Crawler
- func (c *Crawl) Get(url string) *Crawl
- func (c *Crawl) GetBytes(url string, data *[]byte) *Crawl
- func (c *Crawl) GetJSON(url string, out interface{}) *Crawl
- func (c *Crawl) Method(method string) *Crawl
- func (c *Crawl) PostForm(url string, data url.Values) *Crawl
- func (c *Crawl) PostJSON(url string, data interface{}) *Crawl
- func (c *Crawl) PostXML(url string, data interface{}) *Crawl
- func (c *Crawl) Process(processor Processor) *Crawl
- func (c *Crawl) Query(query url.Values) *Crawl
- func (c *Crawl) QueryAdd(key, value string) *Crawl
- func (c *Crawl) QuerySet(key, value string) *Crawl
- func (c *Crawl) RequestOpt(options ...RequestOption) *Crawl
- func (c *Crawl) Run(ctx context.Context) (err error)
- func (c *Crawl) SetBody(data io.Reader, contentType string) *Crawl
- func (c *Crawl) Url(url string) *Crawl
- func (c *Crawl) With(crawler *Crawler) *Crawl
- type Crawler
- func (c *Crawler) ClientOpt(options ...ClientOption) *Crawler
- func (c *Crawler) CookieEnabled(enabled ...bool) *Crawler
- func (c *Crawler) Crawl() *Crawl
- func (c *Crawler) Enqueue(crawl *Crawl) *Crawler
- func (c *Crawler) ErrTry(trySleep func(i int) time.Duration) *Crawler
- func (c *Crawler) GetCookie(u *url.URL, key string) string
- func (c *Crawler) MaxTry(maxTry int) *Crawler
- func (c *Crawler) RequestOpt(options ...RequestOption) *Crawler
- func (c *Crawler) SetCookie(u *url.URL, cookie *http.Cookie)
- func (c *Crawler) Start(ctx context.Context) error
- type Processor
- func ProcessBytes(readBytes func(data []byte) error) Processor
- func ProcessDownload(fn string, report func(cur, total int64)) Processor
- func ProcessJSON(out interface{}) Processor
- func ProcessProgress(readBody func(body io.Reader) error, report func(cur, total int64)) Processor
- func ProcessXML(out interface{}) Processor
- type ProxyFunc
- type RequestOption
- func Accept(accept string) RequestOption
- func AcceptEncoding(acceptEncoding string) RequestOption
- func AcceptLanguage(acceptLanguage string) RequestOption
- func ContentType(contentType string) RequestOption
- func DefaultOption() RequestOption
- func FormUrlencoded() RequestOption
- func HeaderDel(keys ...string) RequestOption
- func HeaderSet(key, value string) RequestOption
- func KeepAlive(keepAlive ...bool) RequestOption
- func Referer(referer string) RequestOption
- func UserAgent(userAgent string) RequestOption
- type RequestOptionFunc
- type RequestOptions
Constants ¶
View Source
const ( CharsetUTF8 = "utf-8" MimeNone = "" MimeFormUrlencoded = "application/x-www-form-urlencoded" MimeFormUrlencodedUTF8 = MimeFormUrlencoded + "; " + CharsetUTF8 MimeJSON = "application/json" MimeJSONUTF8 = MimeJSON + "; " + CharsetUTF8 MimeXML = "text/xml" MimeXMLUTF8 = MimeXML + "; " + CharsetUTF8 )
View Source
const HeaderContentType = "Content-Type"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClientOption ¶
type ClientOptionFunc ¶
func (ClientOptionFunc) Apply ¶
func (fn ClientOptionFunc) Apply(client *http.Client)
type ClientOptions ¶
type ClientOptions []ClientOption
func (ClientOptions) Apply ¶
func (opts ClientOptions) Apply(client *http.Client)
type Crawl ¶
type Crawl struct {
// contains filtered or unexported fields
}
func (*Crawl) RequestOpt ¶
func (c *Crawl) RequestOpt(options ...RequestOption) *Crawl
RequestOpt 请求配置
type Crawler ¶
type Crawler struct {
// contains filtered or unexported fields
}
func (*Crawler) ClientOpt ¶
func (c *Crawler) ClientOpt(options ...ClientOption) *Crawler
func (*Crawler) CookieEnabled ¶
func (*Crawler) RequestOpt ¶
func (c *Crawler) RequestOpt(options ...RequestOption) *Crawler
type Processor ¶
func ProcessBytes ¶
func ProcessDownload ¶
func ProcessJSON ¶
func ProcessJSON(out interface{}) Processor
func ProcessProgress ¶
func ProcessXML ¶
func ProcessXML(out interface{}) Processor
type RequestOption ¶
func Accept ¶
func Accept(accept string) RequestOption
func AcceptEncoding ¶
func AcceptEncoding(acceptEncoding string) RequestOption
func AcceptLanguage ¶
func AcceptLanguage(acceptLanguage string) RequestOption
func ContentType ¶
func ContentType(contentType string) RequestOption
func DefaultOption ¶
func DefaultOption() RequestOption
func FormUrlencoded ¶
func FormUrlencoded() RequestOption
func HeaderDel ¶
func HeaderDel(keys ...string) RequestOption
func HeaderSet ¶
func HeaderSet(key, value string) RequestOption
func KeepAlive ¶
func KeepAlive(keepAlive ...bool) RequestOption
func Referer ¶
func Referer(referer string) RequestOption
func UserAgent ¶
func UserAgent(userAgent string) RequestOption
type RequestOptionFunc ¶
func (RequestOptionFunc) Apply ¶
func (fn RequestOptionFunc) Apply(req *http.Request)
type RequestOptions ¶
type RequestOptions []RequestOption
func (RequestOptions) Apply ¶
func (opts RequestOptions) Apply(req *http.Request)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.