1

I want pull the number of indexed results for a URL on Google into Google Sheets.

Some methods that others in the SEO community have reported to not work are:

  • IMPORTXML and the XPATH for the class that shows how many results for a URL
  • URLFetchApp.Fetch / Regex and IMPORTFROMWEB (add on)

Specifically, I'm looking for the number of indexed URLs there are for a CELL reference.

I found this article that does it from within Google sheets like this:

function isPageIndexed(url)
{
   url = "https://www.google.com/search?q=site:"+url;
      var options = {
     'muteHttpExceptions': true,
     'followRedirects': false
   };
   var response = UrlFetchApp.fetch(url, options);
   var html     = response.getContentText();
   if (html.match(/Your search -.*- did not match any documents./) ){
     return "URL is Not Indexed";
   }
   else {
     return "URL is Indexed";
   }
}

However, they go on to say:

First test this for very few urls. If you want to test multiple urls means the best option is use proxy.

Quite literally half the purpose of doing this in a spreadsheet would be to get multiple results.

That being said, if I'd be inclined to do this via the Google Search Console API. I'm skeptical as to why others have taken a scraping approach if GSC has an API and the Coverage data exists (amongst many other data that might be desired in Sheets).

Please let me know in the comments if I can clarify anything.

2
  • Site searches on Google don't give accurate results counts. What are you playing to use this data for? Sep 21, 2021 at 2:00
  • I'm sorry Mike, I must be missing something. Isn't this built into Google Search Console already? You just have to combine the sheets for Covered>Indexed, Not Submitted in Sitemap and Coverage>Submitted and Indexed.
    – Trebor
    Sep 21, 2021 at 2:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.