2
<table cellspacing="0" cellpadding="0" width="90%" align="center" border="0">
<tr>
<td>
<table cellpadding="0" cellspacing="1" width="90%" border="0" align="center">
<tr>
<td
整个第二个表格位于第一个表格的td标签内。Node.js Cheerio解析html表格内的html表格
我是新来的cheerio。我不能完全得到我的输出,只给出了内部表tr的值。我得到两张桌子,这很混乱。
$ = cheerio.load(html.toString());
var data = [];
$('tr').each(function(i, tr){
var children = $(this).children();
var itemNum = children.eq(0);
var row = {
"Num": itemNum.text().trim()
};
data.push(row);
console.log(row);
});
任何帮助表示赞赏 – user3911976