Skip to main content
deleted 5 characters in body
Source Link
Haluk
  • 1.5k
  • 2
  • 6
  • 18
<!DOCTYPE html>
<html>
  
  <body>
<div dir="ltr">
   <div dir="ltr">
      <div align="center">
         <div style="font:20pt Times New Roman"><b>TITLE</b></div>
         <br></br>
         <table cellspacing="1" cellpadding="3" border="0">
         <tbody>
            <tr align="left">
               <td colspan="2"><b>Account: </b></td>
               <td colspan="5"><b>Name: a</b></td>
               <td colspan="2"><b>Currency: USD</b></td>
               <td colspan="2"><b>Leverage: </b></td>
               <td colspan="3" align="right"><b>2024 June 22, 09:14</b></td>
            </tr>
            <tr align="left"><td colspan="13"><b>Closed Transactions:</b></td></tr>
            <tr align="center" bgcolor="#C0C0C0">
            <td>Ticket</td>
            <td>Open Time</td>
            <td>Type</td>
            <td>Size</td>
            <td>Item</td>
            <td>Price</td>
            <td>S / L</td>
            <td>T / P</td>
            <td>Close Time</td>
            <td>Price</td>
            <td>Commission</td>
            <td>Taxes</td>
            <td>Swap</td>
            <td>Profit</td>
            </tr>
         </tbody>
         </table>
      </div>
   </div>
</div> 
   </body>
</html>
<!DOCTYPE html>
<html>
  
  <body>
<div dir="ltr">
   <div dir="ltr">
      <div align="center">
         <div style="font:20pt Times New Roman"><b>TITLE</b></div>
         <br></br>
         <table cellspacing="1" cellpadding="3" border="0">
         <tbody>
            <tr align="left">
               <td colspan="2"><b>Account: </b></td>
               <td colspan="5"><b>Name: a</b></td>
               <td colspan="2"><b>Currency: USD</b></td>
               <td colspan="2"><b>Leverage: </b></td>
               <td colspan="3" align="right"><b>2024 June 22, 09:14</b></td>
            </tr>
            <tr align="left"><td colspan="13"><b>Closed Transactions:</b></td></tr>
            <tr align="center" bgcolor="#C0C0C0">
            <td>Ticket</td>
            <td>Open Time</td>
            <td>Type</td>
            <td>Size</td>
            <td>Item</td>
            <td>Price</td>
            <td>S / L</td>
            <td>T / P</td>
            <td>Close Time</td>
            <td>Price</td>
            <td>Commission</td>
            <td>Taxes</td>
            <td>Swap</td>
            <td>Profit</td>
            </tr>
         </tbody>
         </table>
      </div>
   </div>
</div> 
   </body>
</html>
<!DOCTYPE html>
<html> 
<body>
<div dir="ltr">
   <div dir="ltr">
      <div align="center">
         <div style="font:20pt Times New Roman"><b>TITLE</b></div>
         <br></br>
         <table cellspacing="1" cellpadding="3" border="0">
         <tbody>
            <tr align="left">
               <td colspan="2"><b>Account: </b></td>
               <td colspan="5"><b>Name: a</b></td>
               <td colspan="2"><b>Currency: USD</b></td>
               <td colspan="2"><b>Leverage: </b></td>
               <td colspan="3" align="right"><b>2024 June 22, 09:14</b></td>
            </tr>
            <tr align="left"><td colspan="13"><b>Closed Transactions:</b></td></tr>
            <tr align="center" bgcolor="#C0C0C0">
            <td>Ticket</td>
            <td>Open Time</td>
            <td>Type</td>
            <td>Size</td>
            <td>Item</td>
            <td>Price</td>
            <td>S / L</td>
            <td>T / P</td>
            <td>Close Time</td>
            <td>Price</td>
            <td>Commission</td>
            <td>Taxes</td>
            <td>Swap</td>
            <td>Profit</td>
            </tr>
         </tbody>
         </table>
      </div>
   </div>
</div> 
</body>
</html>
added 6 characters in body
Source Link
Haluk
  • 1.5k
  • 2
  • 6
  • 18

I tried your sample HTML file by creating the file "index.html" in the script editor, after editing your double quotion marks to singleafter editing your double quotion marks to single and used the below script for getting the date-time value in the table.

I tried your sample HTML file by creating the file "index.html" in the script editor, after editing your double quotion marks to single and used the below script for getting the date-time value in the table.

I tried your sample HTML file by creating the file "index.html" in the script editor, after editing your double quotion marks to single and used the below script for getting the date-time value in the table.

Source Link
Haluk
  • 1.5k
  • 2
  • 6
  • 18

I tried your sample HTML file by creating the file "index.html" in the script editor, after editing your double quotion marks to single and used the below script for getting the date-time value in the table.

index.html file is;

<!DOCTYPE html>
<html>
 
  <body>
<div dir="ltr">
   <div dir="ltr">
      <div align="center">
         <div style="font:20pt Times New Roman"><b>TITLE</b></div>
         <br></br>
         <table cellspacing="1" cellpadding="3" border="0">
         <tbody>
            <tr align="left">
               <td colspan="2"><b>Account: </b></td>
               <td colspan="5"><b>Name: a</b></td>
               <td colspan="2"><b>Currency: USD</b></td>
               <td colspan="2"><b>Leverage: </b></td>
               <td colspan="3" align="right"><b>2024 June 22, 09:14</b></td>
            </tr>
            <tr align="left"><td colspan="13"><b>Closed Transactions:</b></td></tr>
            <tr align="center" bgcolor="#C0C0C0">
            <td>Ticket</td>
            <td>Open Time</td>
            <td>Type</td>
            <td>Size</td>
            <td>Item</td>
            <td>Price</td>
            <td>S / L</td>
            <td>T / P</td>
            <td>Close Time</td>
            <td>Price</td>
            <td>Commission</td>
            <td>Taxes</td>
            <td>Swap</td>
            <td>Profit</td>
            </tr>
         </tbody>
         </table>
      </div>
   </div>
</div> 
   </body>
</html>

and the script where I used "XmlService" is;

function getDateData() {   
      var html = HtmlService.createTemplateFromFile('index').evaluate().getContent();
      html = html.replace(/(\r\n|\n|\r)/gm,"");

      var tablesMatch = html.match(/<table(.*?)<\/table>/gm);
      if (tablesMatch) {
        var myTable = tablesMatch[0];
//        Logger.log(myTable);

        var doc = XmlService.parse(myTable); 
        var rows = doc.getDescendants().filter(function(c) {
          var element = c.asElement();
          return element && element.getName() == "tr";
        });
       
        var data = rows.slice(0).map(function(row) {
          return row.getChildren("td").map(function(cell) {
            return cell.getValue();
          });
        });

        Logger.log(data[0][4]);
  }
}

The screenshot after rıunning the script is added below;

enter image description here