Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 获取上一个元素Node.js和cheerio_Javascript_Jquery_Web Scraping_Cheerio - Fatal编程技术网

Javascript 获取上一个元素Node.js和cheerio

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<

我目前正在使用cheerio使用node.js。我需要在表之前检索上一个“b”元素

<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()