Loading Light/Dark Toggle
Back to Blog

Google SERP API Pagination: Collect Results With start

Alex Johnson
Alex Johnson

Senior Web Scraping Engineer

12-Nov-2026

TL;DR:

  • Google web-search pagination uses start offsets. Keep the query and locale fixed while requesting offsets 0, 10, 20, and onward.
  • Ten pages do not imply one hundred organic records. A worked coffee collection returned 95 records across ten pages.
  • Deduplication needs an explicit definition. Those 95 records contained 85 distinct returned link strings, not 85 verified unique destination pages.
  • A bounded loop needs a recorded stop reason. Empty arrays, repeated pages, errors, and the page limit represent different outcomes.

Introduction: Collect More Than the First Page

Google SERP API pagination is a sequence of related observations. Each request asks for another offset of the same search, and each response needs its own context.

This tutorial uses Scrapeless Google Search API to request up to ten web-search pages. It preserves each response, keeps the offset beside every retained record, and distinguishes raw rows from deduplicated link strings. The example is useful for deeper topic discovery and inspection of search coverage. It does not establish a complete top-one-hundred ranking dataset.

The Google Search endpoint controls define web-search offsets, while the actor request pattern explains the surrounding API call. Keep the search mode fixed throughout the collection.

How start Changes the Request

The start parameter selects the result offset for a web-search request. The ordinary page sequence is 0, 10, 20, and so on.

The offset is a request control, not a count of how many organic records the preceding response happened to contain. If one page returns nine organic records, the next request in this example still uses the next configured offset. Advancing by len(organic_results) would mix the response count with the pagination contract.

Keep q, gl, hl, and any explicit filters unchanged. If you change the country halfway through a run, the combined array no longer describes a single search configuration. Store the full input object with each page so that this mistake remains detectable.

The example omits num and tbm. It is a web-search pagination example; other modes must be checked separately. Consult the current parameter definitions instead of transferring offsets between modes.

A Ten-Page Example With Uneven Page Sizes

A collection for q=coffee, gl=us, and hl=en returned organic records on all ten requested offsets. Each request completed with HTTP 200 in this sample.

start Returned Organic Records
0 9
10 9
20 9
30 9
40 10
50 10
60 10
70 9
80 10
90 10
Total 95

Exact equality of the returned link strings produced 85 distinct values. That calculation does not follow redirects, compare canonical tags, or establish content identity. Two different links can lead to one page; two different pages can also share a domain. Neither hostname grouping nor raw string comparison proves unique destination coverage.

This example establishes that the configured offsets returned data in one collection. It is not a guarantee that every query exposes ten nonempty pages. Search results can change while a multi-request collection is running.

Build a Bounded Pagination Collector

The collector makes at most ten search submissions, saves each completed response, and stops early when it sees an empty organic array or an identical result page. It records an error as an error and keeps already collected data.

Prerequisites are Python, Requests, and SCRAPELESS_API_KEY set in the environment. Install Requests with python -m pip install requests, save the program as paginate_google.py, and run python paginate_google.py. The output goes into a new directory under pagination-runs.

The request helper handles both completed and pending tasks. It submits each search once and uses the existing task's result endpoint when necessary. The pending-task workflow defines that distinction; the code's limits are local policy choices.

python Copy
import json
import os
import time
from pathlib import Path
from urllib.parse import quote

import requests

BASE = "https://api.scrapeless.com/api/v1/scraper"


def google_search(query):
    headers = {"x-api-token": os.environ["SCRAPELESS_API_KEY"]}
    response = requests.post(
        BASE + "/request", headers=headers,
        json={"actor": "scraper.google.search", "input": query},
        timeout=(10, 60), allow_redirects=False,
    )
    task_id = None
    for poll in range(11):
        response.raise_for_status()
        if response.status_code not in (200, 201):
            raise RuntimeError(f"Unexpected HTTP status: {response.status_code}")
        data = response.json()
        if not isinstance(data, dict):
            raise ValueError("Expected a JSON object")
        if response.status_code == 200:
            return data
        if task_id is None:
            task_id = data.get("taskId")
        if not isinstance(task_id, str) or not task_id:
            raise ValueError("Pending response has no taskId")
        if poll == 10:
            raise TimeoutError(f"Task still pending; retain taskId={task_id}")
        time.sleep(2)
        response = requests.get(
            BASE + "/result/" + quote(task_id, safe=""),
            headers=headers, timeout=(10, 30), allow_redirects=False,
        )


def organic_rows(data):
    rows = data.get("organic_results")
    if not isinstance(rows, list):
        raise ValueError("organic_results is missing or is not an array")
    if not all(isinstance(row, dict) for row in rows):
        raise ValueError("organic_results contains a non-object item")
    return rows


if __name__ == "__main__":
    from datetime import datetime, timezone
    run_dir = Path("pagination-runs") / datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%S%fZ")
    run_dir.mkdir(parents=True)
    seen_links = set()
    seen_pages = set()
    collected = []
    summary = []
    stop_reason = "page_limit"
    try:
        for start in range(0, 100, 10):
            query = {"q": "coffee", "gl": "us", "hl": "en", "start": start}
            data = google_search(query)
            (run_dir / f"page-{start}.json").write_text(
                json.dumps({"input": query, "response": data}, ensure_ascii=False, indent=2),
                encoding="utf-8",
            )
            rows = organic_rows(data)
            signature = json.dumps(rows, sort_keys=True, ensure_ascii=False)
            repeat = bool(rows) and signature in seen_pages
            seen_pages.add(signature)
            new_count = 0
            for index, row in enumerate(rows, start=1):
                link = row.get("link")
                usable_link = isinstance(link, str) and bool(link.strip())
                if usable_link and link in seen_links:
                    continue
                if usable_link:
                    seen_links.add(link)
                collected.append({"start": start, "array_index": index, "result": row})
                new_count += 1
            summary.append({"start": start, "returned": len(rows), "kept": new_count})
            if not rows:
                stop_reason = "empty_organic_array"
                break
            if repeat:
                stop_reason = "identical_result_page"
                break
    except (requests.RequestException, ValueError, RuntimeError, TimeoutError) as exc:
        stop_reason = "error:" + type(exc).__name__
        raise
    finally:
        (run_dir / "collected.json").write_text(json.dumps(collected, ensure_ascii=False, indent=2), encoding="utf-8")
        report = {"pages": summary, "stop_reason": stop_reason, "kept_rows": len(collected)}
        (run_dir / "summary.json").write_text(json.dumps(report, indent=2), encoding="utf-8")
        print(json.dumps(report))

The finally block writes a summary even if a later page fails. A failed page is not added as an empty page. The previously saved page files remain available for inspection, and the raised exception still makes the program fail visibly.

Start Scraping with Scrapeless

Power up your web scraping and automation workflow with Scrapeless!
Sign up today and get $5 in free credit — no credit card required.

Claim your free credit now in the Scrapeless Dashboard.

Choose Conservative Deduplication Rules

The collector deduplicates nonempty returned link strings exactly and retains rows with missing links. That policy is easy to audit because it does not rewrite URL components.

The URI normalization model explains why URL comparison requires explicit rules. Blindly deleting query strings, changing path case, or collapsing slash variants can erase meaningful distinctions. Add stronger normalization only after validating the target websites involved.

All raw page records remain in the page files, even when the combined output keeps only the first occurrence of a repeated link. For occurrence analysis, read those page files rather than the deduplicated collection. Otherwise you would lose the evidence that a link appeared at more than one offset.

The repeated-page safeguard compares serialized result records. It detects exact repeated data; it does not claim to identify every near-duplicate SERP. A bounded page limit remains necessary because small field changes can make two visually similar responses compare differently.

Interpret Empty Pages and Partial Runs

An empty organic array is a stop condition in this collector, not proof that Google has no more indexed pages about the topic. Missing arrays and malformed records remain validation failures.

Stop Reason What the Collector Observed Safe Interpretation
page_limit The configured page budget was reached The collection is complete to its configured budget
empty_organic_array A completed response had zero organic records This run stopped at that offset
identical_result_page The organic records exactly repeated Further collection was stopped by the safeguard
error:... A request or parsing step failed The dataset is partial

General HTTP status semantics help distinguish transport outcomes, while your application must still record collection completeness. A successful first page does not make a failed later page successful.

For scheduled work, assign a run identifier and retain timestamps, inputs, offsets, and stop reasons. This follows the practical purpose of data provenance: later consumers should be able to trace a derived dataset back to the observations and transformations that produced it.

Conclusion: Report Depth and Coverage Separately

A pagination report should show requested offsets, completed pages, raw rows, and the deduplication rule. Those measurements answer different questions and should remain separate in both code and prose.

Use the Google Search API product page for service details and current pricing when budgeting deeper collections. A ten-page budget is a collection setting, not a promise of one hundred final URLs.

Join developers working with search data in our community: Discord · Telegram.

Create a Scrapeless account and apply this tutorial to a small query set before scheduling a larger collection.

FAQ

Q: Should start increase by the number of returned rows?

No. Follow the web-search offset sequence. A page with nine organic records does not change the next configured offset.

Q: Does ten-page collection always return one hundred results?

No. The worked collection returned 95 organic records. Page size and availability must be measured from each response.

Q: Are 85 distinct link strings the same as 85 unique webpages?

No. Exact string deduplication does not verify redirects, canonical identity, or page content.

Q: Should an HTTP error be stored as an empty page?

No. Store failure separately and mark the run partial. An empty completed array has a different meaning.

Q: Does pagination.next need to be fetched directly from Google?

No. This client keeps requests on the Scrapeless endpoint and supplies the configured start value. It does not fetch Google navigation URLs directly.

Q: Can the collector run without an AI agent?

Yes. It is a standalone Python program with a bounded sequential page loop.

At Scrapeless, we only access publicly available data while strictly complying with applicable laws, regulations, and website privacy policies. The content in this blog is for demonstration purposes only and does not involve any illegal or infringing activities. We make no guarantees and disclaim all liability for the use of information from this blog or third-party links. Before engaging in any scraping activities, consult your legal advisor and review the target website's terms of service or obtain the necessary permissions.

Most Popular Articles

Catalogue