Javascript 获取上一个元素Node.js和cheerio
我目前正在使用cheerio使用node.js。我需要在表之前检索上一个“b”元素Javascript 获取上一个元素Node.js和cheerio,javascript,jquery,web-scraping,cheerio,Javascript,Jquery,Web Scraping,Cheerio,我目前正在使用cheerio使用node.js。我需要在表之前检索上一个“b”元素 <table style="font-size:13px" width="100%" cellspacing="0" cellpadding="10" border="1"> <tbody> <tr> <td>Question<
<table style="font-size:13px" width="100%" cellspacing="0" cellpadding="10" border="1">
<tbody>
<tr>
<td>Question</td>
<td>No</td>
<td>No > Yes</td>
<td>Yes > No</td>
<td>Yes</td>
<td>IDK</td>
</tr>
</tbody>
</table>
但是我没有得到预期的结果
有什么建议吗?
谢谢大家 您选择的是tr,而不是表格。我也没有看到任何b
const TABLEF_SELECTOR = '.col-lg-6 > table:nth-child(14) > tbody > tr:not(:first-child)'
prev = $(TABLEF_SELECTOR).prev()
table = $(prev).closest('table')
tprev = $(table).prev()