An easy way to get all the link URLs of a webpage

Open the javascript console in your browser, if you’re using Chrome hit CTRL+SHIFT+J and if you’re using Firefox CTRL+SHIFT+K will display the console.

Input the following code and you will get a list of the addresses all the HTML anchors are pointing at.

links = document.links;
for (i = 0; i < (links.length); i++) {
   console.log(links[i].href);
}

links[i] is an HTMLAnchorElement, if you need different property about the href tag just get a different property of HTMLAnchorElement.

Leave a Reply

Your email address will not be published. Required fields are marked *