const crypto = require('crypto');
const https = require('https');
const querystring = require('querystring');
const zlib = require('zlib');
// 生成随机十六进制字符串
function randomHex(len) {
return crypto.randomBytes(Math.ceil(len / 2)).toString('hex').slice(0, len);
}
// 读取环境变量
const ltdj = process.env.ltdj;
if (!ltdj) {
console.error('请设置环境变量 ltdj,格式为 手机号&密码');
process.exit(1);
}
const [account, password] = ltdj.split('&');
if (!account || !password) {
console.error('环境变量 ltdj 格式错误,应为 手机号&密码');
process.exit(1);
}
// 随机生成 deviceId 和 oaid
const deviceId = randomHex(16);
const oaid = randomHex(16);
// 请求体
const postData = querystring.stringify({
account,
appname: '乐淘短剧',
password,
deviceId,
oaid
});
// 请求选项
const options = {
hostname: 'yx1509.bjwjxt.cn',
path: '/api/Member/Alogin',
method: 'POST',
headers: {
'version': '1045',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData),
'User-Agent': 'okhttp/4.10.0',
'Accept-Encoding': 'gzip',
'Connection': 'Keep-Alive'
}
};
// 发送请求
const req = https.request(options, (res) => {
const chunks = [];
res.on('data', chunk => chunks.push(chunk));
res.on('end', () => {
const buffer = Buffer.concat(chunks);
const contentEncoding = res.headers['content-encoding'];
// 处理可能的 gzip 压缩
if (contentEncoding && contentEncoding.includes('gzip')) {
zlib.gunzip(buffer, (err, decompressed) => {
if (err) {
console.error('解压失败:', err.message);
process.exit(1);
}
handleResponse(decompressed.toString());
});
} else {
handleResponse(buffer.toString());
}
});
});
req.on('error', e => {
console.error('请求失败:', e.message);
process.exit(1);
});
req.write(postData);
req.end();
function handleResponse(jsonStr) {
try {
const resp = JSON.parse(jsonStr);
if (resp.code === 1 && resp.data?.userinfo?.token) {
const token = resp.data.userinfo.token;
// 输出 token deviceId oaid(空格分隔)
console.log(`${token} ${deviceId} ${oaid}`);
} else {
console.error('登录失败:', resp.msg || '未知错误');
process.exit(1);
}
} catch (e) {
console.error('解析响应失败:', e.message);
process.exit(1);
}
}
有青龙的创建js脚本
使用方法
1. 在青龙面板新建定时任务,脚本类型选择 Node.js。
2. 将上述代码粘贴到脚本内容中。
3. 在环境变量中添加 ltdj,值为 手机号&密码(如 13800138000&mypassword)。
4. 运行脚本,日志将输出 token deviceId oaid,可供后续任务使用。
注意事项
· deviceId 和 oaid 均为 16 位随机十六进制字符串,每次运行不同。
· 请求头中的 version 固定为 1045,如需更新可自行修改。
![图片[1]-乐淘登录取token➕随机dev以及oaid-暴富社区](https://test.fukit.cn/autoupload/f/cYrp9hTdWD7eQWbwlhdB5diO_OyvX7mIgxFBfDMDErs/20260302/sKys/1200X2608/Screenshot_2026-03-02-11-57-57-894_com.quark.browser.jpg/webp)
© 版权声明
THE END










暂无评论内容