🤬
  • ■ ■ ■ ■ ■ ■
    HowTo/LeaveItToJS/PageProcessing.js
    skipped 18 lines
    19 19   if (clap_num == -1)
    20 20   break;
    21 21   if (clap_num > 50)
    22  - clp_wrts.push(GetWriteupInfo(wrt_xpath));
     22 + clp_wrts.push(await GetWriteupInfo(wrt_xpath));
    23 23   else
    24  - emp_wrts.push(GetWriteupInfo(wrt_xpath));
     24 + emp_wrts.push(await GetWriteupInfo(wrt_xpath));
    25 25   }
    26 26   
    27 27   console.log("writeups is procssed.");
    skipped 22 lines
    50 50   if (clap_num == -1)
    51 51   break;
    52 52   if (clap_num > 50)
    53  - clp_wrts.push(GetWriteupInfo(wrt_xpath));
     53 + clp_wrts.push(await GetWriteupInfo(wrt_xpath));
    54 54   else
    55  - emp_wrts.push(GetWriteupInfo(wrt_xpath));
     55 + emp_wrts.push(await GetWriteupInfo(wrt_xpath));
    56 56   }
    57 57   
    58 58   console.log("writeups is procssed.");
    skipped 28 lines
    87 87  }
    88 88   
    89 89   
    90  -function GetWriteupInfo(wrt_xpath) {
    91  - name_xpath1 = wrt_xpath + "/div/div/div[2]/a/div/section/div[2]/div/h3";
    92  - name_xpath2 = wrt_xpath + "/div/div/div[2]/div/section/div/div/a/h3";
    93  - name_xpath3 = wrt_xpath + "/div/div/div[2]/a/div/section/div[2]/div/p[1]/strong";
    94  - name_xpath4 = wrt_xpath + "/div/div/div[2]/div/section/div/div/h3/a";
    95  - name_xpath5 = wrt_xpath + "/div/div/div[2]/a/div/section/div[2]/div/p[1]";
    96  - name_xpath6 = wrt_xpath + "/div/div/div[2]/div/section/div/div/a/p[1]";
     90 +async function GetWriteupInfo(wrt_xpath) {
     91 + name_xpaths = [
     92 + "/div/div/div[2]/a/div/section/div[2]/div/h3",
     93 + "/div/div/div[2]/div/section/div/div/a/h3",
     94 + "/div/div/div[2]/a/div/section/div[2]/div/p[1]/strong",
     95 + "/div/div/div[2]/div/section/div/div/h3/a",
     96 + "/div/div/div[2]/a/div/section/div[2]/div/p[1]",
     97 + "/div/div/div[2]/div/section/div/div/a/p[1]",
     98 + "/div/div/div[2]/a/div/section/div[2]/div/h4",
     99 + "/div/div/div[2]/div/section/div/div/p"
     100 + ];
    97 101   a_xpath = wrt_xpath + "/div/div/div[2]/a";
    98 102   date_xpath = wrt_xpath + "/div/div/div[1]/div/div/div[2]/div/a";
    99 103  
    100  - name_el = GetElementByXpath(name_xpath1);
    101  - if (name_el == null)
    102  - name_el = GetElementByXpath(name_xpath2);
    103  - if (name_el == null)
    104  - name_el = GetElementByXpath(name_xpath3);
    105  - if (name_el == null)
    106  - name_el = GetElementByXpath(name_xpath4);
    107  - if (name_el == null)
    108  - name_el = GetElementByXpath(name_xpath5);
    109  - if (name_el == null)
    110  - name_el = GetElementByXpath(name_xpath6);
     104 + name_el = null;
     105 + for (let i=0; i<name_xpaths.length; i++) {
     106 + console.log(i);
     107 + name_el = GetElementByXpath(wrt_xpath + name_xpaths[i]);
     108 + if (name_el != null)
     109 + break;
     110 + }
    111 111  
    112 112   name = name_el.textContent;
    113 113   link = GetElementByXpath(a_xpath).href.split("?")[0];
    skipped 78 lines
Please wait...
Page is in error, reload to recover