title: Retrieving text from within div using node.js
body: <p>I am currently trying to write a scraper that will get all the 'p' tags from within a div inside a facebook post using node.js</p>
  
  <p>Each of the posts on the page lie within div's that all have this class: .text_exposed_root</p>
  
  <p>There is sometimes multiple 'p' tags within each post so ideally i need to grab all of the html text within that div if possible. I am using cheerio and request modules and my code so far is below:</p>
  
  <pre><code>request(BTTS, function(error, response, body){
      if (!error){
          var $ = cheerio.load(body), 
          post = $(".text_exposed_root p").text();
  
          console.log(post);
      } else {
          console.log("We’ve encountered an error: " + error);
      }
  })
  </code></pre>
  
  <p>I have tried using .text .value and .html but they all just return a blank response. I'm guessing I would need to grab all the 'p' tags within that div and convert to a string maybe?</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDITED:</p>
  
  <pre><code>var url = ('https://www.facebook.com/BothTeamsToScore');
  
  request({url:url, headers: headers}, function(error, response, body){
      if (!error){
  
          var strippedBody = body.replace(/&lt;!--[\s\S]*?--&gt;/g, "")
  
          console.log(strippedBody);
  
          var $ = cheerio.load(strippedBody), 
          post = $(".text_exposed_root p").text();
  
          console.log(post);
      } else {
          console.log("We’ve encountered an error: " + error);
      }
  })
  </code></pre>