Technical SEO (#5): How Can I Scoop Up All Links and Anchors in a Flash with Google Dev Tools?

How Can I Scoop Up All Links and Anchors in a Flash with Google Dev Tools?

Hey there, fellow lazy website owners! Ever wished you could snatch up all the links and anchors from a webpage faster than you can say “SEO magic”? Well, buckle up, because I’ve got just the trick for you!

With just a few clicks in the Google Dev Tools console, you can scoop up all those juicy links and their accompanying anchor texts in a flash. Here’s how:

javascript

var links = document.querySelectorAll('a[href]');

links.forEach(function(link) {

  var url = link.getAttribute('href');

  var anchorText = link.innerText;

  console.log('URL:', url);

  console.log('Anchor Text:', anchorText);

});

Simply open up the Dev Tools console (you know the drill—hit F12 or right-click and select “Inspect” then head over to the “Console” tab, then write allow pastin), paste in this snazzy little code snippet, and bam! You’ve got yourself a neat list of all the links and their corresponding anchor texts ready for your lazy perusal.

Now, why would you want to do this, you ask? Well, the possibilities are endless 👿 ! You could spy on your competitors’ linking strategies, double-check that all your internal links are ship-shape, or simply satisfy your curiosity about what’s lurking beneath the surface of the web.

So next time you find yourself in need of some link and anchor action, just remember this handy little code snippet.

Happy link hunting, fellow lazy owners!

Was this article helpful?
YesNo
Leave a Reply 0

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


× Contact me