Documentation ¶
Overview ¶
Package client configure http client that used for qidian requests.
Index ¶
- Variables
- func ContextUserAgent(ctx context.Context) string
- func For(ctx context.Context) *http.Client
- func GetAsset(ctx context.Context, url string) (body []byte, err error)
- func With(ctx context.Context, v *http.Client) context.Context
- func WithAssetCache(ctx context.Context, v AssetCache) context.Context
- func WithJavaScriptEngine(ctx context.Context, v JavaScriptEngine) context.Context
- func WithUserAgent(ctx context.Context, v string) context.Context
- type AssetCache
- type GetHTMLOption
- type GetHTMLOptions
- type GetHTMLResult
- type JavaScriptEngine
Constants ¶
This section is empty.
Variables ¶
View Source
var CaptchaDelay = 1 * time.Minute
View Source
var Default = new(http.Client)
View Source
var DefaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0"
Functions ¶
func ContextUserAgent ¶ added in v0.3.0
func WithAssetCache ¶ added in v0.4.0
func WithAssetCache(ctx context.Context, v AssetCache) context.Context
func WithJavaScriptEngine ¶ added in v0.3.0
func WithJavaScriptEngine(ctx context.Context, v JavaScriptEngine) context.Context
Types ¶
type AssetCache ¶ added in v0.4.0
type AssetCache interface { Set(ctx context.Context, key string, body []byte) (err error) Get(ctx context.Context, key string) (body []byte, ok bool, err error) }
var DefaultAssetCache AssetCache = NewInMemoryAssetCache()
func ContextAssetCache ¶ added in v0.4.0
func ContextAssetCache(ctx context.Context) AssetCache
func NewInMemoryAssetCache ¶ added in v0.4.0
func NewInMemoryAssetCache() AssetCache
type GetHTMLOption ¶ added in v0.3.0
type GetHTMLOption func(opts *GetHTMLOptions)
func GetHTMLOptionVisitRequest ¶ added in v0.3.0
func GetHTMLOptionVisitRequest(visitor func(req *http.Request)) GetHTMLOption
type GetHTMLOptions ¶ added in v0.3.0
type GetHTMLOptions struct {
// contains filtered or unexported fields
}
type GetHTMLResult ¶ added in v0.3.0
type GetHTMLResult struct {
// contains filtered or unexported fields
}
func GetHTML ¶ added in v0.3.0
func GetHTML(ctx context.Context, url string, options ...GetHTMLOption) (res GetHTMLResult, err error)
func (GetHTMLResult) Body ¶ added in v0.3.0
func (obj GetHTMLResult) Body() []byte
func (GetHTMLResult) Request ¶ added in v0.3.0
func (obj GetHTMLResult) Request() *http.Request
func (GetHTMLResult) Response ¶ added in v0.3.0
func (obj GetHTMLResult) Response() *http.Response
type JavaScriptEngine ¶ added in v0.3.0
type JavaScriptEngine interface { // Run unsafeJS code, supports `eval` `escape`. Run(ctx context.Context, unsafeJS string) (output string, err error) }
var DefaultJavaScriptEngine JavaScriptEngine
func ContextJavaScriptEngine ¶ added in v0.3.0
func ContextJavaScriptEngine(ctx context.Context) JavaScriptEngine
func NewNodeJSEngine ¶ added in v0.3.0
func NewNodeJSEngine(nodePath string) JavaScriptEngine
Click to show internal directories.
Click to hide internal directories.