0

I had did same thing in JQuery (http://jsfiddle.net/nkishore518/e98b0brb/10/) it is working, but in node.js it is not showing any result and there is no error also. please help me what I had missed.

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);
        });
Kishore Reddy
  • 886
  • 3
  • 11
  • 19
  • there is no rows on the table – Overmachine Oct 02 '15 at 15:43
  • @Overmachine: At the time of my testing it have the rows, but still the header also a row in the table. – Kishore Reddy Oct 02 '15 at 18:27
  • The page doesn't exist any more, but the fundamental problem is likely to be that a script on the page injected the content you want after the static HTML in the page loaded. The reason jQuery works is probably that the HTML you copied wasn't taken from the static HTML. You'll need to hit their API or use a dynamic webdriver like Puppeteer. See [How can I scrape pages with dynamic content using node.js?](https://stackoverflow.com/questions/28739098/how-can-i-scrape-pages-with-dynamic-content-using-node-js) – ggorlen Jul 02 '21 at 17:13

0 Answers0