<img alt="Post image" class="_2_tDEnGMLxpM6uOa2kaDB3 ImageBox-image media-element _1XWObl-3b9tPy64oaG6fax" src="https://preview.redd.it/g64fe51e6z851.jpg?width=640&crop=smart&auto=webp&s=c5917f6…" style="max-height: 512px;">
axios
.get(mainUrl)
.then((response) => {
dealWithData(response.data);
})
.catch((err) => {
console.log(err);
});
const dealWithData = (html) => {
const $ = cheerio.load(html);
const urlMeme = $("._2_tDEnGMLxpM6uOa2kaDB3.ImageBox-image.media-element._1XWObl-3b9tPy64oaG6fax");
const indexValue = 0;
console.log(`Source is:
${urlMeme[indexValue].attribs.src}`);
};
const randNo = (limit) => {
const thatNo = Math.floor(Math.random() * limit);
return thatNo;
};
const indexValue = randNo(urlMeme.length);