title: How to pull HTML table data with Cheerio in Google Apps Script?
body: <p>Inspired by such a convenience of Cheerio from <a href="https://stackoverflow.com/questions/69335854/why-error-on-line-4-element-type-n-length-with-google-apps-scripts-xlmservic/69337145?noredirect=1#comment122572179_69337145">this answer</a>, I'm trying to use it in the following codes.  The codes was able to pull any table data by calling class=&quot;snapshot-td2&quot;, but I'm interested in getting only those in the first table.  How can I do that?  The URL has two tables having class=&quot;snapshot-td2&quot;.  And it retrieved them in string.  How can I get them in array?  Thank you for any help!</p>
  <pre><code>function test() {
    const url = 'https://finviz.com/quote.ashx?t=AFRM';
    const res = UrlFetchApp.fetch(url, { muteHttpExceptions: true }).getContentText();
    const page = Cheerio.load(res);
  
    // The next line returned the tableValue from two tables of having class=&quot;snapshot-td2&quot;.
    // What should be modified to get the tableValue only from the first table? 
    // The next line returned the tableValue in string.  What should be modified to get them in array?
    var tableValue = page('.snapshot-td2').text();
    console.log(tableValue);
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Yait5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yait5.png" alt="enter image description here" /></a></p>