Documentation
¶
Index ¶
- Variables
- func AddURLQueryArgs(a string, args url.Values) string
- type Client
- func (c *Client) Client() *http.Client
- func (c *Client) DoRequest(ctx context.Context, method, u string, header http.Header, body []byte) (*http.Response, []byte, error)
- func (c *Client) DumpTransaction(req *http.Request, resp *http.Response, reqBody, respBody []byte, tryNum int)
- func (c *Client) Get(ctx context.Context, u string, args url.Values, header http.Header) ([]byte, error)
- func (c *Client) GetExtIPAddrInfo(ctx context.Context) (string, error)
- func (c *Client) GetFile(ctx context.Context, u string, args url.Values, header http.Header, ...) (string, error)
- func (c *Client) GetJSON(ctx context.Context, u string, args url.Values, header http.Header, ...) error
- func (c *Client) GetQueryDoc(ctx context.Context, u string, args url.Values, header http.Header) (*goquery.Document, error)
- func (c *Client) Post(ctx context.Context, u string, header http.Header, body []byte) ([]byte, error)
- func (c *Client) PostForm(ctx context.Context, u string, args url.Values, header http.Header) ([]byte, error)
- func (c *Client) PostFormParseJSON(ctx context.Context, u string, args url.Values, header http.Header, ...) error
- func (c *Client) PostJSON(ctx context.Context, u string, header http.Header, data interface{}) ([]byte, error)
- func (c *Client) PostJSONParseJSON(ctx context.Context, u string, data interface{}, header http.Header, ...) error
- func (c *Client) Reset() error
- func (c *Client) SetDumpDir(dir string) error
- func (c *Client) SetMaxTries(n int)
- func (c *Client) SetProxyURLs(urls []string)
- func (c *Client) SetUserAgents(ua []string)
Constants ¶
This section is empty.
Variables ¶
var DefaultUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
"(KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DoRequest ¶
func (c *Client) DoRequest( ctx context.Context, method, u string, header http.Header, body []byte, ) (*http.Response, []byte, error)
DoRequest performs an HTTP request
func (*Client) DumpTransaction ¶
func (c *Client) DumpTransaction( req *http.Request, resp *http.Response, reqBody, respBody []byte, tryNum int, )
DumpTransaction dumps an HTTP transaction content into a file
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, u string, args url.Values, header http.Header) ([]byte, error)
Get perform a GET request
func (*Client) GetExtIPAddrInfo ¶
GetExtIPAddrInfo returns information about client's external IP address
func (*Client) GetFile ¶
func (c *Client) GetFile(ctx context.Context, u string, args url.Values, header http.Header, fPath string) (string, error)
GetFile gets a file and stores it on the disk.
If fPath doesn't contain an extension, it will be added automatically. In case of success file extension returned
func (*Client) GetJSON ¶
func (c *Client) GetJSON(ctx context.Context, u string, args url.Values, header http.Header, target interface{}) error
GetJSON performs a GET HTTP request and parses the response into a JSON
func (*Client) GetQueryDoc ¶
func (c *Client) GetQueryDoc(ctx context.Context, u string, args url.Values, header http.Header) (*goquery.Document, error)
GetQueryDoc performs a GET request and transform response into a goquery document
func (*Client) Post ¶
func (c *Client) Post(ctx context.Context, u string, header http.Header, body []byte) ([]byte, error)
Post performs a POST request
func (*Client) PostForm ¶
func (c *Client) PostForm(ctx context.Context, u string, args url.Values, header http.Header) ([]byte, error)
PostForm posts a form
func (*Client) PostFormParseJSON ¶
func (c *Client) PostFormParseJSON(ctx context.Context, u string, args url.Values, header http.Header, target interface{}) error
PostFormParseJSON performs a POST request and parses JSON response
func (*Client) PostJSON ¶
func (c *Client) PostJSON(ctx context.Context, u string, header http.Header, data interface{}) ([]byte, error)
PostJSON posts a JSON request
func (*Client) PostJSONParseJSON ¶
func (c *Client) PostJSONParseJSON(ctx context.Context, u string, data interface{}, header http.Header, target interface{}) error
PostJSONParseJSON performs a POST request having JSON body and parses JSON response