Bookmarklet to Scrape the Search Engine Results

As an SEO, working with the search engine results pages at a search engine, there comes a time when you need a list of URLs. For example, sometimes you need to export or scrape the search engine results pages for URLs. Let’s say that you’re looking to get a list of URLs that are currently showing up in the search engine results pages. More specifically, I’ve needed to use search operator at Google in order to get a list of all pages that appear in the search results. I will take that list of URLs and put it into a crawler to crawl all of those web pages myself to extract meta data. Or, I have a list of pages from a website I’ve crawled–and want to compare that list of URLs with the list of URLs that’s actually showing up in the Google search engine results pages. Whatever you use that list of URLs for, it doesn’t really matter–but what does matter is how you get that list of URLs.

Not a Coder? No Problem.

For many of us, we’re not necessarily coders or web developers, we don’t want to bother coding something that gets the list of URLs. In fact, if we were to code something, it would be better to use the Google API, and that list isn’t necessarily going to match up with the list that you’re actually seeing, right now, in the search engine results pages. Especially because of customization, Google may show you something else in the SERPs when you search versus when you get a list of URLs from using a script that’s run using the Google API. Or even if you’re not using the API, there might be something different in the search results.

So, if you’re not a coder, like me, I needed a solution to just grab the list of URLs in the search engine results.

I created a bookmarklet (which is essentially a bookmark in your web browser) that you can click when you’re viewing search engine results. It gives you a list of URLs in the SERPs. It’s simple, quick, and works in your web browser. You don’t need to install or use any sort of “add on”, and it works in most web browsers, including Firefox, Google Chrome, and Safari.

The Hartzer SERPs Bookmarklet

The Hartzer SERPs bookmarklet is very simple to use–it’s just one click. Here’s how to install it, and the code that you need to copy/paste into the bookmarklet.

  1. First, you’ll need to know how to add a bookmarklet to your web browser. I prefer to turn on the Bookmarks toolbar in my browser. That’s the easiest thing to do, because of the need to click the bookmarklet.
  2. Once you’ve turned on your bookmarks toolbar in your browser, right-click on the toolbar, and click “add bookmark” as shown below:
    Add bookmark
  3. Once you click Add Bookmark… (I’m using Firefox in this case), You’ll be shown a way to add the bookmark details, as shown below:
    Edit/add bookmark
  4. You’ll then need to name it (i.e., Hartzer SERPs), then enter the JavaScript code in the URL, as shown below:
    Enter Name and Code in URL field
  5. Then click Save, and the bookmarklet will show up on your bookmarks toolbar. This part is important, because you need easy access to this bookmarklet. You need to be able to click it when you’re viewing the Google search engine results page.

There are other ways to add a bookmarklet, such as you can edit a current bookmarklet in your bookmarks toolbar and just rename it and add the JavaScript code in the URL field in the bookmark. You can also add a bookmark and then drag it up to your bookmarks toolbar.

How to Use the Hartzer SERPs Bookmarklet

The process of using the Hartzer SERPs bookmarklet is really very simple once you have it installed/added on your bookmarks toolbar. Here’s how to use it:

  1. Perform a search at Google. For example, let’s search for Hartzer Consulting:
    Hartzer Consulting Google Search
  2. Once you are on the search results page, click on the bookmarklet, the one you just created. Hopefully it is in your bookmarks toolbar so it’s easy to click. Once clicked, you’ll see this page opened up in a new tab in your web browser, looking something like this:
    Hartzer SERPs bookmarklet results
  3. From here, you can copy the text in the box and paste it wherever you need it. I prefer to paste it into Notepad, or just paste it into Google Sheets or Microsoft Excel. From there, I can easily remove the Google URLs and ignore them. The list of the URLs in the search engine results will be there, in order.

Hopefully this bookmarklet will save you a bunch of time, as it does help me a lot when I’m just wanting a simple list of URLs that are in the search engine results–without having to rely on coding or opening or even opening another app. It’s right there in my web browser, as a bookmark.

Code for the Hartzer SERPs Bookmarklet

I’ve created two versions of the bookmarklet, one pulls the list of URLs in a few different formats (a list of anchor text links, for example) as well as the plain text version. I prefer the plain text version most of the time.

Here’s the code of the plain text version (most popular):

javascript:(function(){ str = "<link%20href=''%20rel='stylesheet'%20type='text/css'>\n"; anchors = document.getElementsByTagName("a"); var listing = ""; for (i = 0; i < anchors.length; i++) { var anchorLink = anchors[i].href; listing += anchorLink + "\n"; } str += "<h2>Plain Listing</h2><textarea%20cols=80%20rows=10>"; str += listing; str += "</textarea><br/>%C2%A0<br/><p%20align=center><a%20href=''>Bookmarklet%20by%20Bill%20Hartzer%20of%20Hartzer%20Consulting</a></p>"; with ( { document.write(str); document.close(); } })();

And here’s the longer version, that adds additional formats:

javascript:(function(){ str = "<link%20href=''%20rel='stylesheet'%20type='text/css'>\n"; anchors = document.getElementsByTagName("a"); str += "<table>"; str += "<tr><th>#</th><th>HREF</th><th>Anchor</th></tr>\n";%20%20%20var%20k%20=%200;%20%20%20var%20listing%20=%20"";%20%20%20var%20links%20=%20"";%20%20%20var%20anchorTexts%20=%20"";%20%20%20var%20linksAnchors%20=%20"";%20%20%20%20for%20(i%20=%200;%20i%20<%20anchors.length;%20i++)%20{%20%20%20%20%20var%20anchorText%20=%20anchors[i].textContent;%20%20%20%20%20var%20anchorLink%20=%20anchors[i].href;%20%20%20%20%20var%20linkAnchor%20=%20anchorLink%20+%20"\t"%20+%20anchorText;%20%20%20%20%20%20listing%20+=%20anchorLink%20+%20"\n";%20%20%20%20%20links%20+=%20"<a%20href=\""%20+%20anchorLink%20+%20"\">"%20+%20anchorText%20+%20"</a>\n";%20%20%20%20%20anchorTexts%20+=%20anchorText%20+%20"\n";%20%20%20%20%20linksAnchors%20+=%20linkAnchor%20+%20"\n";%20%20%20%20%20k%20=%20k%20+%201;%20%20%20%20%20%20if%20(anchorText%20===%20undefined)%20anchorText%20=%20anchors[i].innerText;%20%20%20%20%20%20str%20+=%20"<tr>";%20%20%20%20%20str%20+=%20"<td>"%20+%20k%20+%20"</td>";%20%20%20%20%20str%20+=%20"<td><a%20href="%20+%20anchors[i].href%20+%20">"%20+%20anchors[i].href%20+%20"</a></td>";%20%20%20%20%20str%20+=%20"<td>"%20+%20anchorText%20+%20"</td>";%20%20%20%20%20str%20+=%20"</tr>\n";%20%20%20}%20%20%20%20str%20+=%20"</table><br/>%C2%A0<br/><h2>Plain%20Listing</h2><textarea%20cols=80%20rows=10>";%20%20%20str%20+=%20listing;%20%20%20str%20+=%20"</textarea><br/>%C2%A0<br/><h2>HTML%20Links</h2><textarea%20cols=80%20rows=10>";%20%20%20str%20+=%20links;%20%20%20str%20+=%20"</textarea><br/>%C2%A0<br/><h2>Anchors</h2><textarea%20cols=80%20rows=10>";%20%20%20str%20+=%20anchorTexts;%20%20%20str%20+=%20"</textarea><br/>%C2%A0<br/><h2>Links%20Anchors%20</h2><textarea%20cols=80%20rows=10>";%20%20%20str%20+=%20linksAnchors;%20%20%20str%20+=%20"</textarea><br/>%C2%A0<br/><p%20align=center><a%20href=''>Bookmarklet%20by%20Bill%20Hartzer%20of%20Hartzer%20Consulting</a></p>";%20%20%20%20with%20({%20%20%20%20%20document.write(str);%20%20%20%20%20document.close();%20%20%20}%20})();
Scroll to Top