shawenguan 1 год назад
Родитель
Сommit
3fc6cc2e5c
1 измененных файлов с 12 добавлено и 14 удалено
  1. 12 14
      Scripts/telecom/cloud189Helper.js

+ 12 - 14
Scripts/telecom/cloud189Helper.js

@@ -30,9 +30,9 @@ async function Main() {
         magicJS.logger.info(`用户信息:${username}#${password}`);
         await login(username,password);
         let loginUrl = await getLoginUrl();
-        if(loginUrl){
-            await getLoginData(loginUrl);
-        }
+        // if(loginUrl){
+        //     await getLoginData(loginUrl);
+        // }
     }
     magicJS.done();
 }
@@ -46,7 +46,7 @@ function findAll(regexPattern, string) {
     return matches || [];
 }
 
-async function getLoginUrlStep1(){
+async function getLoginJumpUrl(){
     return new Promise((resolve) => {
         let url = 'https://m.cloud.189.cn/udb/udb_login.jsp?pageId=1&pageKey=default&clientType=wap&redirectURL=https://m.cloud.189.cn/zhuanti/2021/shakeLottery/index.html';
         let body = ``;
@@ -65,7 +65,7 @@ async function getLoginUrlStep1(){
         magicJS.http.get(options).then(resp => {
             const data = resp.body;
             try {
-                magicJS.logger.info(`接口数据:${data}`);
+                // magicJS.logger.info(`页面数据:${data}`);
                 let urlMatch = data.match(/https?:\/\/[^\s'"]+/); // 正则表达式匹配
                 if(urlMatch){
                     resolve(urlMatch[0]);
@@ -74,7 +74,7 @@ async function getLoginUrlStep1(){
                 resolve();
             }
         }).catch(err => {
-            const msg = `获取数据异常\n${err}`;
+            const msg = `获取页面数据异常\n${JSON.stringify(err)}`;
             magicJS.logger.error(msg);
             reject(msg);
         });
@@ -82,7 +82,7 @@ async function getLoginUrlStep1(){
 }
 
 
-async function getLoginUrlStep2(url){
+async function getLoginAccoutUrl(url){
     return new Promise((resolve) => {
         let body = ``;
         let options = {
@@ -99,7 +99,7 @@ async function getLoginUrlStep2(url){
         magicJS.http.get(options).then(resp => {
             const data = resp.body;
             try {
-                magicJS.logger.info(`接口数据:${data}`);
+                // magicJS.logger.info(`页面数据:${data}`);
                 let urlMatch = data.match(/<a id="j-tab-login-link"[^>]*href="([^"]+)"/); // 正则表达式匹配
                 if(urlMatch){
                     resolve(urlMatch[0]);
@@ -108,7 +108,7 @@ async function getLoginUrlStep2(url){
                 resolve();
             }
         }).catch(err => {
-            const msg = `获取数据异常\n${err}`;
+            const msg = `获取页面数据异常\n${JSON.stringify(err)}`;
             magicJS.logger.error(msg);
             reject(msg);
         });
@@ -118,13 +118,11 @@ async function getLoginUrlStep2(url){
 
 async function getLoginUrl(){
     let retUrl = null;
-    magicJS.logger.info('###########0');
-    let jumpUrl = await getLoginUrlStep1();
-    magicJS.logger.info('###########1');
+    let jumpUrl = await getLoginJumpUrl();
     if(jumpUrl){
-        retUrl = await getLoginUrlStep2(jumpUrl);
+        retUrl = await getLoginAccoutUrl(jumpUrl);
     }
-    magicJS.logger.info('###########2');
+    magicJS.logger.info(`${retUrl}`);
     return retUrl;
 }