вопрос по cheerio
Добрый день. Недавно начал работать с cheerio, собственно возник вопрос и не могу разобраться:
url = 'http://amfoot.ru/?r=stats/matchAF&match=584&comp=64'; needle.get(url, function (err, res) { if (err) throw (err); var $ = cheerio.load(res.body); var player = []; $('.stats-item').each(function () { player.push({ fio: $(' .stats-personLink ', this).text().replace(/\s{2,}/g, ' ').trim(), }); }) console.log(player); }) При таком методе выдёргивания player.fio содержит имя каждого игрока в отдельном индексе(Т.Е. player.fio[0] - Иванов Иван, player.fio[1] - Петров Пётр и тд.). Но если я начинаю указывать класс, который выше $('.stats-match_leftCol').each(function () { player.push({ fio: $('.stats-item > td > .stats-personLink ', this).text().replace(/\s{2,}/g, ' ').trim(), }); }), то результаты выдаёт склеив их по каттегориям(T.E. player.fio[0] - Иванов Иван, player.fio[1] - Петров ПётрСидоров СидрПример Примеров и тд). Как бы сделать так, что б при работе с верхним классом все люди были разложены отдельно:help: ? Заранее спасибо. Пы. Сы: Структура того места в исходном коде <td class="stats-match_leftCol"> <h3 class="stats-header">Пас</h3> <div class="stats-table_wrapper"> <table class="stats-table datagrid datagrid_zebra"> <colgroup> <col/> <col class="stats-counterCol" width="50px"/> <col class="stats-counterCol" width="50px"/> <col class="stats-counterCol" width="50px"/> <col class="stats-counterCol" width="50px"/> </colgroup> <thead class="datagrid_thead"> <tr> <th> </th> <th class="main-rightAlign">%</th> <th class="main-rightAlign">яр</th> <th class="main-rightAlign">тд</th> <th class="main-rightAlign">пер</th> </tr> </thead> <tbody class="datagrid_tbody"> <tr class="stats-item"> <td> <a class="stats-personLink" href="/?r=person/view&person=1149&comp=64">Михаил Сатюков</a> </td> |
Часовой пояс GMT +3, время: 02:22. |