let sites = [];
document.addEventListener("DOMContentLoaded", function (e) {
let links = document.querySelectorAll('a');
console.log(links);
links.forEach(link => {
let site = {
"name": link.outerText,
"url": link.href
}
// console.log(site);
sites.push(site);
})
console.log(JSON.stringify(sites));
})
Get All Links on a HTML Page
2022-02-23