I am executing below code snippet but it is not redirecting to actual page.
var http = require('http');
var options = {
host: 'google.com',
port: 80,
path: '/search?q=hello+world'
};
http.get(options, function(resp){
resp.setEncoding('utf8');
resp.on('data', function(chunk){
//do something with chunk
console.log('================\n\n', chunk);
});
}).on("error", function(e){
console.log("Got error: " + e.message);
});
Command fire :
node sample.js
Output :
================
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.co.in/search?q=hello+world&gws_rd=cr&dcr=0&ei=Wd3xWd_nBITovgSl9bXwCA">here</A>.
</BODY></HTML>
I want to get entire page html but not this instead of I want results for hello world.