Saturday 27 May 2017

Were to put the body callback from the request.get

I try to get the HTML from the website but is not render on the server anything only on the console

_body how to get the HTML from this site and were to put this body callback

var http = require('http');
var request = require('request');



request.get('https://tesla.com/home', function (err, response, _body) {
  // access data from other web site here
  console.log(_body);




  var server = http.createServer(function(request, response) {
    response.writeHead(200, {"Content-Type": "text/html"});
    response.write(_body);
    response.end();
  });

  server.listen(3000);
  console.log("Server is listening");


});



via George

No comments:

Post a Comment