I want scrape youtube channel i have list 1500 channel list. I want to scrape it one by one through the node. The problem is in the loop I want to stop loop until getting response and process response of the current channel.
async and await
const cheerio = require('cheerio');
const request = require('request');
var fs = require('fs');
async function getTitle(){
var data = await fs.readFileSync('./channels.json');
var Parsed_Data = await JSON.parse(data);
console.log(Parsed_Data);
for (x of Parsed_Data){
// var url = 'https://www.youtube.com/channel/' + x.id + '/about';
// console.log(url);
request( 'https://www.youtube.com/channel/' + x.id + '/about', function(err, res, body) {
let $ = cheerio.load(body);
console.log($);
let title = $('title');
console.log(title.text());
}
)};
want the title of each channel