我正在尝试抓取包含指定文本的整个表,但是在导航它返回的cheerio对象时遇到问题,我是否继续为每个迭代添加.children还是对此有一个更优雅的解决方案?
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)
}
}
}
})
我希望只浏览表格中的文字