mirror of
https://github.com/karl0ss/JDRssDownloader.git
synced 2025-04-27 20:03:40 +01:00
26 lines
588 B
JavaScript
26 lines
588 B
JavaScript
const axios = require('axios');
|
|
var cheerio = require('cheerio');
|
|
|
|
async function getLinksFromURL(url) {
|
|
|
|
try {
|
|
let links = [];
|
|
let httpResponse = await axios.get(url);
|
|
|
|
let $ = cheerio.load(httpResponse.data);
|
|
let linkObjects = $('a'); // get all hyperlinks
|
|
|
|
linkObjects.each((index, element) => {
|
|
links.push(
|
|
$(element).attr('href'), // get the href attribute
|
|
);
|
|
});
|
|
|
|
return links;
|
|
} catch (e) { console.log(e) }
|
|
|
|
}
|
|
|
|
module.exports = {
|
|
getLinksFromURL
|
|
} |