Javascript Node.js在html表中解析html表
此代码修复了该问题。我没有意识到你只是传递元素,直到你得到你需要的元素,然后使用children.eq(n)我能够得到行中的每个td文本值。希望这能帮助其他人。任何帮助都值得感谢Javascript Node.js在html表中解析html表,javascript,html,node.js,parsing,cheerio,Javascript,Html,Node.js,Parsing,Cheerio,此代码修复了该问题。我没有意识到你只是传递元素,直到你得到你需要的元素,然后使用children.eq(n)我能够得到行中的每个td文本值。希望这能帮助其他人。任何帮助都值得感谢 <table cellspacing="0" cellpadding="0" width="90%" align="center" border="0"> <tr> <td> &l
<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
$ = 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);
});
$ = cheerio.load(html.toString());
var data = [];
$('table tr td table tr').each(function(i, td){
var children = $(this).children();
var itemNum = children.eq(0);
var itemName = children.eq(1);