|
|
@@ -117,11 +117,13 @@ async function getLoginUrl(){
|
|
|
}
|
|
|
|
|
|
|
|
|
-function findAll(regexPattern, text) {
|
|
|
- const re = new RegExp(regexPattern); // 'g' 标志表示全局搜索
|
|
|
+function getFieldFromText(regexPattern, text, index=1) {
|
|
|
+ const re = new RegExp(regexPattern);
|
|
|
let matches = text.match(re);
|
|
|
- magicJS.logger.error(JSON.stringify(matches));
|
|
|
- return matches || [];
|
|
|
+ if(matches && matches.length > 0){
|
|
|
+ return matches[index];
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
function getLoginData(url){
|
|
|
@@ -146,10 +148,10 @@ function getLoginData(url){
|
|
|
const htmlText = resp.body;
|
|
|
try {
|
|
|
// magicJS.logger.info(`接口数据:${htmlText}`);
|
|
|
- let captchaToken = findAll(`captchaToken' value='(.+?)'`, htmlText)[0];
|
|
|
- let lt = findAll(`lt = "(.+?)"`, htmlText)[0];
|
|
|
- let paramId = findAll(`paramId = "(.+?)"`, htmlText)[0];
|
|
|
- let j_rsakey = findAll(`j_rsaKey" value="(.+?)"`, htmlText)[0];
|
|
|
+ let captchaToken = getFieldFromText(`captchaToken' value='(.+?)'`, htmlText);
|
|
|
+ let lt = getFieldFromText(`lt = "(.+?)"`, htmlText);
|
|
|
+ let paramId = getFieldFromText(`paramId = "(.+?)"`, htmlText);
|
|
|
+ let j_rsakey = getFieldFromText(`j_rsaKey" value="(.+?)"`, htmlText);
|
|
|
let retData = {
|
|
|
captchaToken: captchaToken,
|
|
|
lt: lt,
|