Sometimes, we need to quickly extract a list of URLs from a Google web search, often for audits or pre-checks to see what Google has indexed. While there are tools available for this task, sometimes a quick analysis is needed. In such cases, a bookmarklet script like the one below can be incredibly useful.
The following code is an AI-enhanced version of the original script found on Chris Ains’s SEO Tools. This bookmarklet allows you to extract URLs directly from Google search results (or any page for that matter), making it easy to gather and analyze the data.
The code below performs a couple of validations as follows:
- It removes any URLs from the extracted list that contain google.com.
- It also eliminates any rows with empty URLs.
javascript: (function() {
var pageAnchors = document.getElementsByTagName('a');
var output = '<table id="extractedLinks"><tr><th>ID</th><th>Link</th><th>Anchor Text</th></tr>';
var validLinkCount = 0;
for (var i = 0; i < pageAnchors.length; i++) {
if (pageAnchors[i].href && pageAnchors[i].href.trim() && !pageAnchors[i].href.includes('google.com')) {
validLinkCount++;
output += '<tr><td>' + validLinkCount + '</td><td><a href="' + pageAnchors[i].href + '">' + pageAnchors[i].href + '</td><td>' + pageAnchors[i].textContent.trim() + '</td></tr>';
}
}
output += '</table>';
var newWindow = window.open('about:blank', 'Extracted Links');
newWindow.document.write(output);
newWindow.document.close();
})();
How to create your bookmarklet.
- Enable ‘Show bookarmks bar’ in Chrome.
- Create a placeholder bookmark. eg: visit Google.com and drop the page in the bookmarks bar.
- Edit the bookmark URL and paste the code from above.
How to use the URL extractor bookmarklet
- Search a domain for indexed pages. eg: site:https://jazzywp.com
- Click the bookmarklet.
- A new tab will open with the extracted links.
Hope this helps! Once you’ve extracted the URLs, simply select all, copy, and paste them into a spreadsheet, and you should be good to go.
Founder, Managing Partner of Jazzy Marketing.
My first foray into the web was back in 2001 when we needed to get a website build for a telecom venture I was working for. I was given the project of getting our website built with e-commerce integration for calling cards – a huge market at the time. Well, that was the spark that got me interested in website development and I have not looked back since.