How to Use Proxies for Paginated Data

Scraping a site without accounting for its pagination is like trying to empty a river with a bucket—you’ll never get it all. Pagination is the hidden layer that separates a complete, reliable dataset from a fragmented mess. But once you understand it, it becomes a tool rather than a hurdle.
Websites paginate for speed, usability, and performance. For scrapers, it means navigating multiple pages, offsets, tokens, or dynamic content. One slip, and your data is incomplete. Nail it, and you unlock structured, exhaustive datasets with precision.

Different Types of Pagination

Websites paginate differently, so recognizing the pattern is crucial.

1. Page-based Pagination

https://example.com/products?page=5

The simplest form. Each page has a number. Predictable. Easy to loop through. But beware—page counts change. Skip one or duplicate another, and your dataset is off. Build scrapers that can adapt to added or missing pages.

2. Offset-based Pagination

https://example.com/products?offset=50&limit=25

Data is sliced using a starting point and a limit. Common in APIs and database-driven sites. But high offsets can slow requests or trigger anti-bot defenses. The trick? Efficiently paginate without hammering the server.

3. Cursor-based (Token-based) Pagination

https://api.example.com/products?cursor=eyJpZCI6IjEyMyJ9

Modern APIs favor this. Each response provides a token pointing to the next batch. Tokens expire fast. Miss it, and you’re stuck. Your scraper must manage tokens carefully, updating with each request.

4. Infinite Scroll / “Load More”

Content loads dynamically as users scroll or click. Social feeds, modern e-commerce—they all use it. HTML parsers alone won’t work. You need headless browsers or AJAX inspection. Timing and precision are everything.

Obstacles in Paginated Content Scraping

Pagination introduces multiple pitfalls. Here’s what trips up most scrapers:

  • Vast datasets: Hundreds of pages, thousands of entries. Your scraper must be resilient.
  • JavaScript content: Infinite scroll content isn’t in the initial HTML. You need advanced techniques to capture it.
  • Rate limits and blocks: Hit too fast and sites respond with CAPTCHAs or IP bans. Rotating proxies is non-negotiable.
  • Duplicate or missing data: Dynamic pagination shifts. Deduplication is crucial.
  • Changing structures: Sites redesign constantly. Yesterday’s scraper can fail tomorrow.

Scraping Paginated Data

No single approach works everywhere. Choose based on the pagination style.

Static HTML (Page-based)

import requests
from bs4 import BeautifulSoup

base_url = "https://example.com/products?page={}"

for page in range(1, 6):
    url = base_url.format(page)
    response = requests.get(url)
    soup = BeautifulSoup(response.text, "html.parser")
    
    for item in soup.select(".product-title"):
        print(item.get_text())

Loop, fetch, parse. Simple. Works when pages are numeric.

Offset-based

import requests

base_url = "https://example.com/products?offset={}andlimit=25"

for offset in range(0, 100, 25):
    url = base_url.format(offset)
    response = requests.get(url)
    data = response.json()
    
    for product in data["products"]:
        print(product["name"])

Increment offsets, request each slice, extract results. Efficient for structured APIs.

Cursor-based

import requests

url = "https://api.example.com/products"
params = {"limit": 25}
has_more = True

while has_more:
    response = requests.get(url, params=params).json()
    for product in response["data"]:
        print(product["name"])
    
    if "next_cursor" in response:
        params["cursor"] = response["next_cursor"]
    else:
        has_more = False

Update the cursor with each request. Repeat until the data is exhausted. Precision is everything.

Infinite Scroll / “Load More”

import requests

url = "https://example.com/v1/scraper"
params = {
    "url": "https://example.com/products?page=1",
    "render_js": True,
    "pagination": "auto"
}

response = requests.get(url, params=params, auth=("API_KEY", ""))
print(response.json())

Scroll, trigger AJAX calls, extract content, repeat. Patience pays off.

Pro Tips for Paginated Scraping

Scraping paginated content isn’t just coding—it’s strategy:

  • Observe website limits: Aggressive scraping risks bans. Implement delays and rate limiting.
  • Using rotating IPs and user agents: Spread requests to mimic human traffic.
  • Remove duplicate results: Infinite scroll or token-based APIs can overlap. Keep datasets clean.
  • Monitor structural changes: Automate checks to detect site updates early.
  • Cache and reuse data: Scrape smarter, save bandwidth, and reduce server load.
  • Follow ethics: Review robots.txt and terms of service. Sustainable scraping is safe scraping.

Final Thoughts

Scraping paginated content doesn’t have to be a headache. By understanding each pagination type, managing offsets and tokens carefully, rotating IPs, and deduplicating results, you turn a complex challenge into a smooth, reliable workflow. Master these practices, and every dataset you collect will be complete and accurate.