There are many useful tools such as Screaming Frog that can crawl your website and provide a nice clean report of all the URLS or email addresses that appear on your website. Here’s a solution, if you are working on an internal website and if you can’t run your crawling tool for some reason. Simply plug this code into your browser’s console window. Please comment out the “if(strURL.includes” line if you only want to see email addresses. Inspiration from TowardsDataScience.
var urls = document.getElementsByTagName('a'); var bolflag=false; for (url in urls) { var strURL=urls[url].href; if(typeof strURL !== 'undefined') { if(strURL.includes("@")==true)//comment me out you just want to see all links including emails { console.log('%c '+strURL, 'background: #222; color: #bada55'); bolflag=true; } }//ends if }//ends loop if(bolflag==false) { console.log('%c NO Emails! ', 'background: #222; color: #bada55'); }
//Grabbing subsection of a page. Example Navigation only var uniqueContent = document.getElementById("PLACEHOLDER_value_UNIQ_DIV");//add a new unique ID to the element you want using browser inspect elements if the html doesn't already have a unique DIV var contentWlink = uniqueContent.querySelectorAll("a"); //can also attempt to combine statements with more advanced CSS selector. CSS is not my strength however. "document.querySelectorAll("ul.vertical-list a"); var myarray = [] for (var i=0; i<contentWlink.length; i++){ var nametext = contentWlink[i].textContent; var cleantext = nametext.replace(/\s+/g, ' ').trim(); var cleanlink = contentWlink[i].href; myarray.push([cleantext,cleanlink]); }; function make_table() { var table = '<table><thead><th>Name</th><th>Links</th></thead><tbody>'; for (var i=0; i<myarray.length; i++) { table += '<tr><td>'+ myarray[i][0] + '</td><td>'+myarray[i][1]+'</td></tr>'; }; var w = window.open(""); w.document.write(table); } make_table(); //Code courtesy of Phil Gorman - https://towardsdatascience.com/quickly-extract-all-links-from-a-web-page-using-javascript-and-the-browser-console-49bb6f48127b