|
|
@ -29,6 +29,7 @@ router.post('/rsCookie', async (req, res) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let jsText; |
|
|
|
let jsText; |
|
|
|
|
|
|
|
let loadHtmlJs; |
|
|
|
if (jsStr == null || jsStr === "") { |
|
|
|
if (jsStr == null || jsStr === "") { |
|
|
|
let jsPath = AreaNameEnum.getByAreaName(areaName).JS_FILE |
|
|
|
let jsPath = AreaNameEnum.getByAreaName(areaName).JS_FILE |
|
|
|
if (jsPath == null) { |
|
|
|
if (jsPath == null) { |
|
|
@ -36,8 +37,10 @@ router.post('/rsCookie', async (req, res) => { |
|
|
|
return res.send('未找到js文件') |
|
|
|
return res.send('未找到js文件') |
|
|
|
} |
|
|
|
} |
|
|
|
jsText = fs.readFileSync(jsPath).toString('utf8'); |
|
|
|
jsText = fs.readFileSync(jsPath).toString('utf8'); |
|
|
|
|
|
|
|
loadHtmlJs = true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
jsText = Buffer.from(jsStr, 'base64').toString('utf-8') |
|
|
|
jsText = Buffer.from(jsStr, 'base64').toString('utf-8') |
|
|
|
|
|
|
|
loadHtmlJs = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -46,7 +49,7 @@ router.post('/rsCookie', async (req, res) => { |
|
|
|
jsText, |
|
|
|
jsText, |
|
|
|
cookie != null && cookie !== "" ? Buffer.from(cookie, 'base64').toString('utf-8') : null, |
|
|
|
cookie != null && cookie !== "" ? Buffer.from(cookie, 'base64').toString('utf-8') : null, |
|
|
|
userAgent != null && userAgent !== "" ? Buffer.from(userAgent, 'base64').toString('utf-8') : null, |
|
|
|
userAgent != null && userAgent !== "" ? Buffer.from(userAgent, 'base64').toString('utf-8') : null, |
|
|
|
uuid) |
|
|
|
uuid, loadHtmlJs) |
|
|
|
|
|
|
|
|
|
|
|
console.log(`${uuid};返回cookie ---->`, cookies.split('; ')) |
|
|
|
console.log(`${uuid};返回cookie ---->`, cookies.split('; ')) |
|
|
|
|
|
|
|
|
|
|
@ -86,7 +89,7 @@ function CookieStr2List(cookies) { |
|
|
|
return list |
|
|
|
return list |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function handle(url, htmlStr, jsText, cookie, userAgent, uuid) { |
|
|
|
async function handle(url, htmlStr, jsText, cookie, userAgent, uuid, loadHtmlJs) { |
|
|
|
// 获取 origin
|
|
|
|
// 获取 origin
|
|
|
|
let baseUrl = new URL(url).origin; |
|
|
|
let baseUrl = new URL(url).origin; |
|
|
|
// 初始化 jsDom 和 cookieJar
|
|
|
|
// 初始化 jsDom 和 cookieJar
|
|
|
@ -121,7 +124,12 @@ async function handle(url, htmlStr, jsText, cookie, userAgent, uuid) { |
|
|
|
// 初始化浏览器
|
|
|
|
// 初始化浏览器
|
|
|
|
browser(window, 'chrome'); |
|
|
|
browser(window, 'chrome'); |
|
|
|
// 加载js
|
|
|
|
// 加载js
|
|
|
|
let js = loadJs(window, jsText); |
|
|
|
let js; |
|
|
|
|
|
|
|
if (loadHtmlJs) { |
|
|
|
|
|
|
|
js = loadJs(window, jsText); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
js = jsText; |
|
|
|
|
|
|
|
} |
|
|
|
console.log(`${uuid};js 加载长度--->`, js.length) |
|
|
|
console.log(`${uuid};js 加载长度--->`, js.length) |
|
|
|
|
|
|
|
|
|
|
|
// 执行 js
|
|
|
|
// 执行 js
|
|
|
@ -134,6 +142,9 @@ async function handle(url, htmlStr, jsText, cookie, userAgent, uuid) { |
|
|
|
if (process.env.NODE_ENV === 'prod') { |
|
|
|
if (process.env.NODE_ENV === 'prod') { |
|
|
|
timeout = 100 |
|
|
|
timeout = 100 |
|
|
|
reTry = 10 |
|
|
|
reTry = 10 |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
timeout = 100 |
|
|
|
|
|
|
|
reTry = 50 |
|
|
|
} |
|
|
|
} |
|
|
|
let val = await store.waitGetAndDelete(uuid, timeout, reTry) |
|
|
|
let val = await store.waitGetAndDelete(uuid, timeout, reTry) |
|
|
|
|
|
|
|
|
|
|
|