title: scraping html tags off website in electron
body: <p>Is there a way to scrape a website in electron. My goal is to be able to go to a website and scrape the html tags. I am using a windows machine so I launch the app(npm start index.html). My thinking was to create a .js file and use <strong>require</strong> (Url, function(err, resp,html){ }) like you can do in node but this does not work in electron. This code is not able to scrape the page and do a callback. I just want the html only. How can I get this done?
  The code in the app.js file that I do a call back on is.</p>
  
  <pre><code>function scrape(callback){ 
  
      var content = [];
      var request = require('request');
      var cheerio = require('cheerio');
      var url = "http://www.amazon.com";
  
  
  
      request(url, function(error, response, html){
  
         if (error){
  
            content.push('Error:', error);
         }
         if (response.statusCode !== 200) {
  
            content.push('Invalid Status Code Returned:', response.statusCode);
       }
  
        content.push(html);
        var $ = cheerio.load(html);
  
  
      $('td').each(function (i, element) {
  
  
          var a = $(this).prev();
          var trimmed_a = a.text();
  
          trimmed_a = trimmed_a.trim();
          var str = trimmed_a.replace(/\s\s+/g,"");
          var newStr = str.trim();
  
         content.push(newStr);
  
      });
  
  
   })
    callback(content);
  }    
  
  module.exports = scrape;
  </code></pre>
  
  <p>The callback works fine but the code is not executed. There is a lot I don't understand so feel free to direct constructively. The goal is to be able to scrape any site with this.</p>