0

This is my code. I want to get data from webpages. As you can see, there are two var $ = cheerio.load(html). The problem is on the inner one I got "cannot read property 'text' of undefined" error. What is the solution?

request(l1,function(error, resposne, html){
    if(!error){
        var $ = cheerio.load(html);
        $('.list').filter(function(){
            //process
        });
        async.series([
           function(callback){
               request(l2,function(error, response, html){
                  var $ = cheerio.load(html); // error here
                  $('li').filter(function(){

                  });
               });
            callback(null, 'one');
         },
           function(callback){

           callback(null, 'two');
         },
           function(err, results){

         });
    }
ZZZ
  • 1,415
  • 5
  • 16
  • 29

0 Answers0