Your scraper works on page one. Then it stops.
The site shows 2,000 products, but you got 24. Or the page keeps loading more items as you scroll, and your HTTP request only ever sees the first batch. That's the pagination problem, and it breaks more scrapers than bad selectors do.
This guide shows how to handle pagination and infinite scroll when scraping: how to spot which pattern a site uses, the loop that fits each one, and the stop rules that keep a crawl from running forever. It builds on my guide to scraping JavaScript-heavy websites, because infinite scroll is usually a rendering problem in disguise.
Tool details below come from the Firecrawl, n8n and Crawlee docs. Some links are affiliate links; they don't change your price.

What are the main pagination patterns?
Almost every listing on the web uses one of five patterns. Name the pattern first and the code mostly writes itself.
| Pattern | What you see | What changes per page | How you know you're done |
|---|---|---|---|
| Page numbers | 1, 2, 3 … Next | A page or offset parameter in the URL | Empty page, or page count reached |
| Next link | A Next button with a real href | The whole URL | No Next link on the page |
| Cursor or token | Often invisible, inside an API call | An opaque cursor from the last response | Cursor is missing or null |
| Load more button | A button under the list | Usually a hidden API call with a page or cursor | Button disappears or is disabled |
| Infinite scroll | New items appear as you scroll | A hidden API call fired by scrolling | Item count stops growing |
The last two look like browser behaviour, but under the hood they're almost always the first three. The button or the scroll event just calls an endpoint with page 2, offset 48 or a cursor. That matters, because calling the endpoint directly is far cheaper than driving a browser.

How do you find out which pattern a site uses?
Spend five minutes in DevTools before you write a loop.
- Click to page 2 and watch the address bar. If a parameter such as page=2, p=2, offset=24 or start=24 appears, you have URL pagination.
- Look at the Next button's HTML. A real href means you can follow links. A button with no href means JavaScript is doing the work.
- Open the Network tab, filter to Fetch/XHR, then click Load more or scroll down. Note the request that fires. Look at its query string and the JSON it returns for fields like page, offset, next, cursor, has_more or total.
- Compare View Source with the live DOM. If the items aren't in View Source, you need either that hidden API call or a browser. My JavaScript scraping guide covers that check in detail.
Before you scale anything, read the site's robots.txt and terms. A paginated crawl makes many more requests than a single scrape, so the rules in my robots.txt guide for scrapers apply with more force here.
How do you scrape page-number and offset pagination?
Increase the parameter until the site returns nothing new. Then stop.
The loop is simple. The stop rule is where people get it wrong.
Some sites return an empty list after the last page. Others quietly return the last page again, or redirect page 999 back to page 1. So check for both "no items" and "no new items".
Offset pagination works the same way. Instead of page=1, 2, 3, you send offset=0, 24, 48 and step by the page size. If the site shows a total count ("2,013 results"), use it to compute the last page, but keep the empty-page check anyway, because counts are often rounded or stale.
A small trick: many sites accept a larger page size, such as per_page=100 or limit=100. Fewer requests means faster runs and less load on the server. Stay within whatever maximum the site or API allows.
How do you follow "Next" links safely?
Read the Next link from each page, request it, and stop when there's no Next link.
This is the most robust pattern for server-rendered sites, because you never guess URLs. You just follow what the site gives you. Look for an anchor with rel="next", a link element with rel="next" in the head, or a button labelled Next with an href.
The visited set does real work here. Some sites loop the last Next link back to page one, and without it your crawler runs in circles until something times out.
How do you handle cursor-based pagination in APIs?
Pass the cursor from each response into the next request, and stop when the cursor comes back empty.
Cursors are common in modern APIs and in the hidden endpoints behind infinite scroll. The response includes a token such as next_cursor, after or a full next URL. You can't jump to page 40. You have to walk the pages in order.
Save the last cursor somewhere as you go. If the run dies at page 300, you can resume from that cursor instead of starting again.
Doing the same in n8n without code
The n8n HTTP Request node has pagination built in, under Add Option, then Pagination. Its docs list two modes.
Update a Parameter in Each Request lets you set a page parameter to the expression {{ $pageCount + 1 }}, since $pageCount starts at zero. Response Contains Next URL lets you point at the next link in the body, for example {{ $response.body["next-page"] }}.
I walk through the node's other settings in my n8n HTTP Request node guide. Check the API's own docs first, because the field names for page size and next links differ from service to service.
How do you scrape a "Load more" button?
First, look for the request the button fires. If you find it, paginate that endpoint directly and skip the browser.
Click Load more with the Network tab open. Most of the time you'll see a JSON or HTML-fragment request with a page, offset or cursor parameter. Treat it like any of the patterns above.
When there's no clean endpoint (signed parameters, heavy anti-bot tokens, or HTML assembled in the browser), click the button in a browser. Firecrawl's scrape endpoint supports browser actions that run in order before the page is captured: wait, click, scroll, press, executeJavascript and scrape. Its docs allow up to 50 actions per request, and the combined wait time across actions and waitFor must stay under 60 seconds.
That 60-second budget means a single request can't click Load more hundreds of times. For long lists, find the underlying endpoint, or split the job. My Firecrawl API examples post has more action patterns you can adapt.
How do you scrape infinite scroll?
Scroll, wait for new items, count them, and stop when the count stops growing.
As with Load more, check the Network tab first. Infinite scroll almost always fetches the next batch from an API as you near the bottom. If you can call that API with a cursor or page number, you get clean JSON and avoid the browser entirely.
If you do need a browser, the loop looks like this in Playwright for Python:
Three things make this reliable. It waits on the item count, not just a fixed sleep. It allows a few stalls before quitting, because a slow API call can look like the end. And it caps the total, so a truly endless feed can't run forever.
If you build on Crawlee, its Playwright utilities include an infiniteScroll helper that scrolls to the bottom, loads dynamic content and keeps going until it times out. That saves you writing the loop yourself.

One more trap: some feeds remove old items from the DOM as you scroll (virtual lists). Your final count stays flat even though new content arrives. In that case, extract items inside the loop and dedupe by URL or ID, rather than reading the page once at the end.
What stop rules and crawl limits should every paginated scraper have?
Every loop needs at least two ways to stop, and one of them should be a hard cap.

- A natural end signal: an empty page, no Next link, a null cursor, or no new items after a few scrolls.
- A hard page or item cap, set from what you actually need.
- A seen set of URLs or IDs, so loops and duplicates can't inflate the run.
- A time or cost budget, especially on paid scraping APIs.
- A delay between requests, plus backoff on errors like 429 Too Many Requests.
Crawlers bake many of these in. Firecrawl's crawl endpoint uses limit to cap pages (it defaults to 10,000), maxDiscoveryDepth to cap link hops, includePaths and excludePaths to scope URLs, and delay to space out requests (setting delay forces concurrency to 1).
It also has an ignoreQueryParameters option, which is useful when the same page appears under many sort and filter parameters. Note that this would also merge ?page=2 into ?page=1, so leave it off when your pagination lives in the query string.
Firecrawl charges 1 credit per crawled page by its docs, so a sensible limit is also a cost control.
Crawlee has the same idea through its own options: enqueueLinks takes a selector, include and exclude patterns, and a limit, and the crawler can be capped with a maximum number of requests per crawl.
If you're getting blocked partway through long paginated runs, slow down before you add proxies. My guide to avoiding proxy bans and CAPTCHAs explains why request rate is usually the first thing to fix.
Which tool should you use for which pattern?
Pick the lightest tool that reaches the data.
| Situation | Lightest fit |
|---|---|
| Page numbers or Next links in plain HTML | HTTP client and an HTML parser, in a loop |
| JSON API with page, offset or cursor | Direct API calls, or the n8n HTTP Request node with pagination |
| Load more or infinite scroll with a clean endpoint | Call the endpoint directly |
| Load more with no usable endpoint, short lists | Firecrawl actions |
| Long infinite scroll, custom logic, scheduling | Playwright or Crawlee, often run on Apify |
| Many paginated listings across a whole site | A crawler with limits: Firecrawl crawl or Crawlee |
For a closer look at the two hosted options, see my Firecrawl vs Apify comparison. Apify suits long-running, scheduled actors. Firecrawl suits quick, clean output from a URL or a scoped crawl.
If you'd rather self-host Playwright or Crawlee jobs, a small Hostinger KVM VPS is what I recommend for running scrapers on a schedule. Set it up with my VPS security checklist before you put anything on it.
Frequently asked questions
Pagination stops being scary once you name the pattern. Check the Network tab, call the cleanest endpoint you can find, and give every loop a natural end signal plus a hard cap. Most of the time, Load more and infinite scroll turn out to be plain page or cursor requests underneath.
Next step: if the pages need a browser to render at all, start with the rendering checks.


