Jay
Jay

Reputation: 11

What am I doing wrong here in NodeJs Cheerio

var cheerio = require('cheerio');
var request = require('request');
request('https://www.mobcrush.com', function(err, resp, body){
    if(!err && resp.statuscode == 200){
        var $ = cheerio.load(body)
        var testing = $('#main-content')
        console.log(testing)
    }
});

Trying to scrape the website but the console log comes up blank

Upvotes: 0

Views: 85

Answers (1)

abdulbari
abdulbari

Reputation: 6242

Everything is fine

you have given statuscode instead of statusCode

  try {
    if (!err && resp.statusCode == 200) {
      console.log('ssss');
      var $ = cheerio.load(body)
      var testing = $('#main-content');
      console.log(testing);
  }
} catch (e) {
   console.log(e)
}

Upvotes: 1

Related Questions