summaryrefslogtreecommitdiff
path: root/bilibili/client.go
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-07-29 19:43:27 +0800
committerKeuin <[email protected]>2023-07-29 20:21:17 +0800
commit9b5c3913989754370bd7d03ac8cf2e32a6172afb (patch)
tree9e2caca8feb9ca5a9c14a96424d23e20db4314bc /bilibili/client.go
parenta153bf02d1cf05f020d263e9670a76ae99cfeb02 (diff)
Simulate real web app cookies & WebSocket fields
Diffstat (limited to 'bilibili/client.go')
-rw-r--r--bilibili/client.go8
1 files changed, 7 insertions, 1 deletions
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,
}