Chrome DevTools Extract all URLs JS Snippet

A forum packed with Technical SEO golden nuggets. Guides, tip, tutorials, PHP snippets and JS scripts straight from Sitebee. We are sharing the technical SEO knowledge and skills that we have learnt over the years.

Sitebee

Freelance Technical SEO
Staff member
Here is a handy JS snippet to extract all URLs within a webpage using the Console within Chrome DevTools.

Code:
var urls = document.getElementsByTagName('a');
for (url in urls) {
    console.log ( urls[url].href );
}
The output will resemble the below:
js-snippet-devtools.PNG


I find this method useful for data extraction. Pulling menu links, hreflang alt URLs, etc. Save it as a bookmarklet to save time pasting in the snippet over and over.