From 236caf67cf23099d96d37379ca67933f98e24e84 Mon Sep 17 00:00:00 2001 From: liudongqi Date: Wed, 4 Sep 2024 15:45:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/routes/index.js b/routes/index.js index bffeed7..3de7b84 100644 --- a/routes/index.js +++ b/routes/index.js @@ -73,6 +73,14 @@ function loadJs(window, jsText) { return js; } +function CookieStr2List(cookies) { + let list = [] + for (let cookie of cookies.trim().split("; ")) { + list.push(cookie); + } + return list +} + async function handle(url, htmlStr, jsText, cookie, userAgent) { let uuid = crypto.randomUUID() // 获取 origin @@ -87,8 +95,12 @@ async function handle(url, htmlStr, jsText, cookie, userAgent) { }) // 设置 cookie if (cookie != null) { - console.log('cookie 加载长度--->', cookie, baseUrl) - cookieJar.setCookieSync(cookie, baseUrl); + console.log(cookie) + let cookieList = CookieStr2List(cookie); + console.log('cookie 加载--->', cookieList, baseUrl) + for (let i = 0; i < cookieList.length; i++) { + cookieJar.setCookieSync(cookieList[i], baseUrl); + } } // 加载dom let dom = await jsDom(htmlStr);