To make
const request = require('request'); request('http://www.google.com', (err, response, html) => if (err) { return console.log(err); } console.log(html.url); console.log(html.explanation); });
Above code send
It can be accessed by:
npm install cheerio
const cheerio = require('cheerio'); const $ = cheerio.load(html);
To parse HTML table you can use cheerioTableparser. Cheerio-
It can be accessed by:
const cheerioTableparser = require('cheerio-tableparser'); const $ = cheerio.load(html); cheerioTableparser($); let data = $("table").parsetable(true, true, true);
Output:
data = > [ [ 'A', '1a', '1a', '1a', '1a', '1a' ], [ 'B', '2a', '2b', '2b', '2d', '2d' ], [ 'C', '3a', '2b', '2b', '3d', '3e' ], [ 'D', '4a', '4b', '4c', '4c', '4e' ], [ 'E', '5a', '5b', '5c', '5d', '5e' ] ]
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Sakshi Gadia
An experienced MEAN Stack developer having good knowledge in Nodejs, MongoDb. Apart from these in my spare time, I enjoy playing chess and ready to learn new technologies.