`scraping with node.js code example

Example 1: node.js web scraping

//eventhough deprecated, still able to use
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.
});

Example 2: `scraping with node.js

//you need to do npm i request
const request = require('request');
//you need to do npm i cheerio
const cheerio = require('cheerio');

// you can add any link in the place of this link 
request('https://www.megekko.nl/product/4278/294823/Socket-AM4-Processoren/AMD-Ryzen-7-5800X-processor', (error, response, html) => {
    if (!error && response.statusCode == 200) {
        const $ = cheerio.load(html);

        //in between the brackets you need to add the class of te thing you want to scrape
        const Price = $('.euro.large');

        console.log(Price.text());

    }
});