我在JQuery中做了同样的事情(http://jsfiddle.net/nkishore518/e98b0brb/10/)它正在工作,但在node.js中它没有显示任何结果,也没有错误。请帮助我错过了。
var request = require('request');
var cheerio = require('cheerio');
var url = "http://www.bseindia.com/markets/equity/stream.aspx";
request({
"uri": url
}, function(err, resp, body){
var $ = cheerio.load(body);
var strContent = "";
$('#divscrips').children('table').find('table').first().find('tr').each(function(index,item){
if(index>0)
{
var tds = $(item).find('td');
strContent += $(tds.eq(1)).text().trim() + ","
+ tds.eq(5).text().trim() + "," + tds.eq(6).text().trim()+ "\r\n";
}
});
console.log(strContent);
});