From 9b5c3913989754370bd7d03ac8cf2e32a6172afb Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 29 Jul 2023 19:43:27 +0800 Subject: Simulate real web app cookies & WebSocket fields --- bilibili/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'bilibili/client.go') diff --git a/bilibili/client.go b/bilibili/client.go index 4abad60..f4b64fd 100644 --- a/bilibili/client.go +++ b/bilibili/client.go @@ -10,6 +10,7 @@ import ( "github.com/keuin/slbr/types" "net" "net/http" + "net/http/cookiejar" ) const ( @@ -39,10 +40,15 @@ func NewBilibiliWithContext(ctx context.Context, netTypes []types.IpNetType, log transport.DialTLSContext = nil transport.DialContext, _ = np.NextNetworkType(dialer) + cookieJar, _ := cookiejar.New(nil) + httpClient := &http.Client{ + Jar: cookieJar, + } + return &Bilibili{ logger: logger, userAgent: userAgent, - http: http.DefaultClient, + http: httpClient, ctx: ctx, netTypes: nets, } -- cgit v1.2.3