'how to get all media url link like all image or video or else using cheerio in node js also backlinks of page
I am using cheerio for web crawling, I want to get all media link URLs like images or videos or else. Is there any function, object, method which is used to get media links also want to fetch all backlinks of the page
Solution 1:[1]
const cherio = require('cherio');
const request = require('request');
const url = "https://www.sdpgroups.com/";
request(url, (err, res, html) => {
try {
if (!err && res.statusCode === 200) {
const $ = cherio.load(html);
// scrapping Images
$("img").each((index, imageElement) => {
const imgUrl = $(imageElement).attr("src");
console.log(imgUrl);
});
} else {
console.log(err)
}
} catch (err) {
console.log(`unhandled error: ${err}`);
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pushp Singh |
