我想網絡使用cheerio和HTTP中的HTML代碼節點JS網絡報廢在nodejs中使用cheerio?
部分抄襲:
<tr>
<td id="priceblock_saleprice_lbl" class="a-color-price a-size-base a-text-right a-nowrap">Sale:</td>
<td class="a-span12">
<span id="priceblock_saleprice" class="a-size-medium a-color-price"><span class="currencyINR"> </span> 585.00</span>
</td>
</tr>
的NodeJS代碼:
var sale_price = '#priceblock_saleprice';
scraper(sale_price).filter(function(){
var data_price = scraper(this);
console.log(data_price.text());
scraped = scraped + data_price.text()+';';
});
this code is giving 585 as output.
,但在相同的:的
部分html頁面:
<tr id="priceblock_ourprice_row">
<td id="priceblock_ourprice_lbl" class="a-color-secondary a-size-base a-text-right a-nowrap">Price:</td>
<td class="a-span12">
<span id="priceblock_ourprice" class="a-size-medium a-color-price"><span class="currencyINR"> </span> 329.00</span>
</td>
</tr>
周
代碼的NodeJS:
var mrp = '#priceblock_ourprice_lbl';
scraper(mrp).filter(function(){
var data_mrp = scraper(this);
console.log(data_mrp.text());
scraped = scraped + data_mrp.text()+';';
});
它是不給輸出。
但它不工作我已經嘗試。 –