I am getting html page of a website by using request of nodejs. Sample code is as :
const request = require('request');
request('http://www.google.com', function (error, response, body) {
console.error('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
});
I want to get the elements of the body by using tags like I would do on a browser console
like body.getElementById("myId");
or document.getElementById()
sort.
Maybe there are multiple ways of doing this with different libraries(node modules), but what is the most efficient way to do this? I will be fetching many pages and I want to get elements by tags possibly using javascript please help me on how to do this.