0

I am attempting to scrape the entire table that contains specified text but having issues navigating through the cheerio object it returns, do I continue adding .children for each iteration or is there a more elegant solution to this?

const test = 'https://www.sec.gov/Archives/edgar/data/24741/000002474118000053/glw-20180930x10q.htm'

const request = require('request');

const cheerio = require('cheerio');

request(test, (error, res, html) => {
  if (!error && res.statusCode == 200) {
    // console.log(html)

    const $ = cheerio.load(html)

    const table = $("tbody:contains('Cash and cash equivalents')")

    // console.log(table[0])

    for (var i in table[0].children){
      for (var j in table[0].children[i].children) {
        console.log(table[0].children[i].children[j].children)
      }
    }

  }
})

I am hoping to get to just the text of the table

kenneh
  • 91
  • 8
  • 1
    Try referencing this previous question https://stackoverflow.com/questions/37098405/javascript-queryselector-find-div-by-innertext/37098508 – Jake Apr 04 '19 at 23:30
  • when can i use document.? its a hit or miss for me – kenneh Apr 04 '19 at 23:42

0 Answers0