Imgur Web Scraping + Callback vs Promise Example in Node.js

Опубликовано: 03 Ноябрь 2024
на канале: JsWiz
7,707
114

Learn advanced scraping: https://goo.gl/QEo1ie

Repo: https://github.com/jakblak/nodeJS_exa...
check imgur_scraping folder

In this video we're going to do a cheerio + request example and scrape the website Imgur. This will also include an example of how to turn a callback into a promise.

Here you will learn how to use the request module and pass in a url to gather the contents of the web page. Then we can use cheerio module to parse the body and extract the elements we want. Then we'll use that data to display the output in our console.

The contents of our scraper will be held in a separate file and then imported into our main app.js file. We'll access the JSON output using a callback. Then we'll refactor this code to show how we can use native Promises to perform the same task.