How to Scrape Paginated and Infinite-Scroll Websites Reliably
paginationinfinite-scrollweb-scrapingbrowser-automationdata-extraction

How to Scrape Paginated and Infinite-Scroll Websites Reliably

WWebscraper.site Editorial Team
2026-12-01
8 min read

A practical checklist for scraping numbered pages, cursor APIs, load-more controls, and infinite scroll without duplicates or missed records.

Reliable pagination is less about clicking “next” and more about identifying how a site obtains the next batch of records. This guide gives you a reusable checklist for scraping numbered pages, cursor-based APIs, load-more controls, and infinite-scroll interfaces while reducing duplicates, missed records, and runaway requests.

Overview

Before building a scraper, determine where pagination state lives and which event changes it. A traditional site may expose a simple URL such as ?page=2. A modern application may request JSON with an offset, send a cursor returned by the previous response, or trigger another request when the user reaches the bottom of the page.

The most dependable workflow is:

  1. Inspect the first page and record the visible results.
  2. Use browser developer tools to identify the request made when the next results appear.
  3. Reproduce that request directly when it is public, stable, and permitted for your use case.
  4. Define a unique record key, a clear stop condition, and a request limit before collecting data.
  5. Validate counts, ordering, and duplicates as the scraper runs.

Direct HTTP requests are usually simpler and faster when the data is available in an HTML document or JSON response. Browser automation with Playwright or Puppeteer is useful when JavaScript must execute, an interaction reveals the next request, or the page has no practical server-side endpoint to call directly. For responsible collection, review the site’s terms, robots.txt guidance, access limits, and privacy considerations before running a job. See How to Scrape Websites Responsibly for that preparation.

Checklist by scenario

Numbered pages

Numbered pagination is the easiest pattern to recognize. Look for links containing page numbers, a “Next” link, or a URL parameter such as page, p, or offset. Confirm that changing the URL actually changes the result set; some interfaces display page controls that are only client-side state.

  • Save the starting URL and canonical page pattern.
  • Parse the next-page link rather than assuming page numbers are consecutive.
  • Stop when there is no next link, the response redirects unexpectedly, or a page contains no new record keys.
  • Check whether filters and sort parameters must be carried forward on every request.

For a page-number scraper, a useful invariant is that each successful page should contribute at least one new record until the final page. If page 4 repeats page 3, pause the job and inspect the URL construction rather than continuing indefinitely.

Offset or limit APIs

Many public-facing JSON requests use parameters such as offset and limit. Record the exact request from the browser’s Network panel, including the method, query parameters, relevant headers, and response shape. Start with a small limit while testing.

  • Increase the offset by the number of records returned, not always by the requested limit.
  • Use the API’s reported total when it is available, but do not rely on it as your only stop condition.
  • Stop on an empty result array or when the response returns no new identifiers.
  • Watch for server-side maximum page sizes and silently capped limits.

Offset pagination can become inconsistent if records are added or removed during a long run. If ordering is not stable, capture a timestamp or other run marker where the interface provides one, and validate the final dataset for missing or repeated records.

Cursor pagination

Cursor pagination uses a token from one response to request the next batch. The token may be named cursor, nextCursor, continuation, or something similar. Do not try to generate cursors yourself. Treat them as opaque values and pass the returned token exactly as required by the next request.

  • Extract the next cursor from the response body, headers, or a link field.
  • Keep the original filters and sort order unchanged.
  • Stop when the cursor is absent, null, unchanged, or accompanied by an empty result set.
  • Store the cursor used for each batch so a failed run can be diagnosed.

Cursor pagination is often safer than guessing page numbers, but it still requires a duplicate check. A repeated cursor can otherwise create an endless loop.

Load-more buttons

A load-more control usually changes the page through a click, but the useful extraction target is the request behind that click. In the Network panel, filter for Fetch or XHR requests, click the control once, and compare the new request with the initial one. Look for an offset, cursor, page value, or request body that changed.

If the response contains structured records, reproduce the request directly where appropriate. If the interaction is tightly coupled to browser state, use automation and wait for the new results rather than waiting an arbitrary number of seconds. Verify that the result count increased after each click and stop when the button is disabled, removed, hidden, or no longer produces new records.

Infinite scroll

To scrape infinite scroll, first distinguish visual scrolling from data retrieval. Scroll near the bottom once, then inspect the request that appears. A page may request data when an intersection observer detects a sentinel element, when the scroll position crosses a threshold, or when a virtualized list needs more rows.

  1. Load the initial page and collect its records.
  2. Trigger one controlled scroll event or wait for the sentinel to load.
  3. Wait for the relevant network response or for the result count to increase.
  4. Extract only the newly available records, using a stable key for deduplication.
  5. Repeat until the request returns no new records or the interface signals completion.

Virtualized lists may remove older elements from the DOM. In that case, do not rely on the current HTML as the complete dataset. Capture each response or newly rendered batch as it arrives. The guide to scraping JavaScript-rendered websites with Playwright covers the browser-automation side of this workflow.

Decision table

PatternBest first approachPrimary stop conditionMain risk
Numbered URL pagesHTTP requests and HTML parsingNo valid next link or no new keysIncorrect page URL or lost filters
Offset APIReproduce JSON requestsEmpty batch or no new keysShifting results during collection
Cursor APIFollow returned cursorMissing or repeated cursorToken mishandling
Load moreInspect click-triggered requestButton disabled or no new batchClick succeeds visually but data does not load
Infinite scrollCapture network responses or automate scrollingNo new records after a controlled triggerVirtualized DOM and timing issues

What to double-check

Identify a stable record key. Prefer a source identifier, canonical URL, or combination of fields that is unlikely to change. If no identifier exists, normalize the URL and selected text fields before hashing or comparing them. Keep the original record as well as the derived key so duplicate decisions can be audited.

Separate retrieval from parsing. Save raw responses or representative fixtures during development. Then parse records in a separate step. This makes it easier to repair selectors without repeatedly requesting the site and supports regression tests when pagination changes. The article on testing web scrapers with fixtures and regression suites provides a practical testing pattern.

Use layered stop conditions. A robust job should stop when any of the following occurs: no next link or token, an empty batch, no new record keys, a repeated cursor, a known total is reached, or a configured maximum page and record limit is met. A maximum is a safety boundary, not proof that the dataset is complete.

Preserve request context. Log the page number, cursor, URL, status, response time, item count, and number of new keys. Redact credentials and sensitive headers. If the response format is JSON, validate required fields before accepting a batch. You can use the principles in validating scraped data with JSON Schema to catch malformed pages early.

Check ordering and completeness. Compare the first and last records in adjacent batches. Look for unexpected jumps, repeated timestamps, identical response bodies, or a result count that stops changing. After extraction, normalize fields and inspect duplicates, missing identifiers, and null-heavy columns using a workflow such as cleaning and normalizing scraped data.

Common mistakes

  • Guessing the pagination scheme: A visible “next” control does not prove that ?page=2 is the correct request. Inspect the actual navigation or network request.
  • Waiting fixed time intervals: A short delay may race the request, while a long delay wastes time. Wait for a response, a selector state change, or a measurable result-count change.
  • Using DOM count as total count: Infinite-scroll and virtualized interfaces may retain only visible rows. Track records as batches arrive.
  • Deduplicating too late: Remove duplicates at ingestion and report both received and unique counts. Late cleanup can hide a broken cursor or repeated page.
  • Ignoring filters and sort order: A next request that omits a filter can silently mix unrelated records into the output.
  • Retrying without limits: Retries need a bounded count, backoff, and a clear distinction between transient failures and an invalid pagination token.
  • Assuming a successful status means valid data: A response can be technically successful while containing an error payload, login page, empty shell, or changed schema.

For the final output, keep raw data separate from cleaned JSON or CSV. That separation makes it possible to trace a questionable record back to the exact page or response that produced it. See the practical web scraping data pipeline guide for an end-to-end structure.

When to revisit

Revisit a pagination scraper before a seasonal planning cycle, after changing its browser-automation or HTTP library, or whenever the target site changes its frontend, filters, sorting, or response format. A small interface redesign can replace numbered links with cursors, move data from HTML into JSON, or change when a load-more request fires.

Use this quick maintenance checklist:

  1. Run the scraper against a known fixture or saved sample and compare record counts.
  2. Inspect one fresh browser session and confirm that the pagination request still exists.
  3. Verify the selector, endpoint, cursor field, filters, and sort order.
  4. Check logs for repeated cursors, duplicate keys, empty batches, and unexpected redirects.
  5. Review rate limits, terms, robots.txt guidance, and privacy requirements for the current use case.
  6. Recheck a small sample manually before allowing a full extraction.

The durable rule is simple: discover the mechanism, follow the returned state, deduplicate as you go, and stop for an explicit reason. That approach works across conventional pagination, cursor-based APIs, load-more controls, and infinite-scroll pages—even when the implementation details change.

Related Topics

#pagination#infinite-scroll#web-scraping#browser-automation#data-extraction
W

Webscraper.site Editorial Team

Senior SEO Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.