SEO

SEO

SEO

Sep 19, 2025

Sep 19, 2025

Sep 19, 2025

How to Scrape URLs from Google SERPs (2 Simple Methods)

In SEO audits and technical SEO, extracting clean URLs from Google’s search results (SERPs) is often necessary.
In this post, I’ll show you two simple methods to scrape URLs directly from SERPs without using any paid tools or extensions:

  1. Console Snippet Method

  2. Bookmarklet Method

Important: Google frequently updates its HTML structure, so scripts like these may stop working at any time. Always stay updated with the latest techniques.

Why Scrape SERP URLs?

  • Competitor Research: Collect the top 50–100 results to identify major competitors.

  • SEO Audits: Export results for title tags, redirects, and canonical analysis.

  • Outreach: Build a list of blogs, media sites, or potential backlink opportunities.

Google usually hides the “real” outbound links behind tracking URLs like /url? or /imgres?. These methods will help you extract direct external URLs while removing duplicates.

Method 1: Console Snippet

Follow these steps:

  1. Go to Google and run a search query (example: digital marketing course in Mumbai).

  2. Press F12 or right-click → InspectConsole.

  3. Enable pasting in the console:

    • Right-click inside the console → choose Allow paste.

  4. Paste the script below and hit Enter:

(() => {
  const as=[...document.querySelectorAll('a[href]')];
  const seen=new Set(), out=[];
  for (const el of as){
    let href=el.getAttribute('href'); if(!href) continue;
    let url=href;
    if (href.startsWith('/url?')||href.startsWith('/imgres?')){
      try{const u=new URL(href,location.origin); url=u.searchParams.get('q')||u.searchParams.get('url')||href;}catch{}
    }
    try{
      const absolute=new URL(url,location.origin);
      const host=absolute.hostname;
      if (el.hasAttribute('ping') && !/(^|\.)(google|gstatic|googleusercontent)\./i.test(host) && !seen.has(absolute.href)){
        seen.add(absolute.href); out.push(absolute.href);
      }
    }catch{}
  }
  console.log(out);
})();

What this does:

  • Scans all <a> tags.

  • Unwraps Google’s redirect links.

  • Filters out Google domains (e.g., google.com, gstatic.com).

  • Prints a unique list of external URLs in the console.

Pro tips:

  • Scroll down the SERP to load “People also ask” and “Images” before running the script.

  • If you see no results, make sure you’re on the classic Google web results page (not in experimental “Labs” or AI overviews).

Method 2: Bookmarklet (One-Click)

Instead of pasting code in the console every time, you can create a bookmarklet that runs with a single click.

Steps:

  1. Open your browser’s Bookmark Manager and create a new bookmark.

  2. Give it a name (e.g., SERP URL Scraper).

  3. Paste the following code into the URL field:

javascript:(function(){try{var as=[...document.querySelectorAll('a[href]')];var seen=new Set();var out=[];for(const el of as){let href=el.getAttribute('href');if(!href)continue;let url=href;if(href.startsWith('/url?')||href.startsWith('/imgres?')){try{const u=new URL(href,location.origin);url=u.searchParams.get('q')||u.searchParams.get('url')||href;}catch(e){}}try{const absolute=new URL(url,location.origin);const host=absolute.hostname;const isGoogle=/(^|\.)(google|gstatic|googleusercontent)\./i.test(host);if(el.hasAttribute('ping')&&!isGoogle&&!seen.has(absolute.href)){seen.add(absolute.href);out.push(absolute.href);}}catch(e){}}var html='<!doctype html><meta charset="utf-8"><title>Outbound links</title><h2>Outbound links ('+out.length+')</h2><ol>'+out.map(u=>'<li><a href="'+u+'" target="_blank" rel="noopener">'+u+'</a></li>').join('')+'</ol>';var w=window.open('','_blank');if(!w){alert('Pop-up blocked. Allow pop-ups for this site and try again.');return;}w.document.open();w.document.write(html);w.document.close();}catch(e){alert('Error: '+e.message);}})();

Run a search query on Google.

  1. Click the bookmark. A new tab will open showing a list of all external links (with counts).

Shortcut: If your bookmarks bar is hidden, press Ctrl+Shift+B to toggle it.

Practical Examples

  • Competitor Research: Run queries like site:flipkart.com iphone to extract product URLs.

  • Client Audit: Search brand-related queries, scrape links, and check redirects, titles, or canonical tags.

  • Content Planning: Collect blog URLs, fetch headings (H1s), and group them into content clusters.


These two methods cover most quick use cases:

  • Console Snippet → fastest way to copy URLs.

  • Bookmarklet → one-click, clickable list in a new tab.

🚨 Disclaimer: Large-scale or automated scraping may violate Google’s Terms of Service. These methods are intended for manual research and learning.