v0.4.6 Latest Latest

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 16 Imported by: 0



Package client configure http client that used for qidian requests.



This section is empty.


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"


func ContextUserAgent added in v0.3.0

func ContextUserAgent(ctx context.Context) string

func For

func For(ctx context.Context) *http.Client

For get client from context.

func GetAsset added in v0.4.0

func GetAsset(ctx context.Context, url string) (body []byte, err error)

func With

func With(ctx context.Context, v *http.Client) context.Context

With set client to context.

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

func WithUserAgent added in v0.3.0

func WithUserAgent(ctx context.Context, v string) context.Context


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

Jump to

Keyboard shortcuts

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