title: Error 429 on scraping from Google search with Google-apps-script
body: <p>I want to get the number of indexed pages for certain domains. Therefore I want to use the &quot;site:&quot; parameter and extract the number of results from the search result page.</p>
  <p>I tried it with a Google-apps-script for Google spreadsheets:</p>
  <pre><code>function sampleFormula_4() {
    const url = &quot;https://www.google.com/search?q=site%3Abenedikt-sahlmueller.de&quot;;
    
    try {
      const html = UrlFetchApp.fetch(url).getContentText();
      return html.match(/&lt;div id=&quot;result-stats&quot;&gt;(.+?)nobr&gt;/)[1].trim();
  
    } catch (e) {
      Utilities.sleep(5000);
      const html = UrlFetchApp.fetch(url).getContentText();
      return html.match(/&lt;div id=&quot;result-stats&quot;&gt;(.+?)nobr&gt;/)[1].trim();
    }
  }
  </code></pre>
  <p>Google Spreadsheet gives me an error 429 - too many requests. I integrated a sleep-time of 5000ms, but Google Search still returns error 429.</p>
  <p>All I need is the number of pages for certain URLs in Google's search results. Maybe there is a better way - I can't use the search-api for this as those pages are not part of my GSC.</p>