Glossary
Pagination: walking through long lists page by page
Pagination is how a site breaks a long result list into smaller chunks, and every scraper that wants the full list has to follow it to the end.
The four styles you will meet
Almost every paginated list uses one of four patterns. Identify the pattern first, because it decides how you build the next request and how you know you are done.
| Style | How the next chunk is requested | How the end looks |
|---|---|---|
| Page number | ?page=3 in the URL | An empty list or a missing Next link |
| Offset and limit | ?offset=60&limit=30 | Fewer items than the limit |
| Cursor | An opaque value from the previous response, such as next_cursor | The cursor is null or absent |
| Infinite scroll | JavaScript loads more when you reach the bottom | The loader stops firing |
Page numbers and offsets
These are the easiest to crawl because you can compute every URL in advance. If the first page says there are 40 pages, you can queue all 40 at once and fetch them in parallel. The risk is drift: if new items are inserted while you crawl, offsets shift and you see some rows twice and miss others. Deduplicate on a stable ID such as a product SKU rather than on position.
Cursors
Cursor pagination hands you a token with each response that points to the next slice. You cannot jump ahead, so the crawl is sequential per list, but it is stable when data changes underneath you. Store the last cursor you processed; if the job stops, you can resume from it instead of starting over. Cursors often expire after a few minutes, so do not hold them overnight.
Infinite scroll
On a page that loads more items as you scroll, the browser is usually calling a JSON endpoint with a page or cursor parameter. Watch the Network panel while scrolling and you will often find a plain paginated API underneath, which you can call directly (see hidden API scraping). If no clean endpoint exists, drive a headless browser that scrolls, waits for new nodes and stops when the item count stops growing.
Detecting the last page reliably
Do not trust a single signal. Combine several: the Next link is missing, the response holds zero items, the items repeat the previous page, or a total count says you have them all. Also set a hard ceiling on pages per list, so a bug in the end check cannot keep a worker looping forever.
Where CAPTCHAs appear in paginated crawls
Deep pages are a classic trigger. A visitor rarely clicks to page 80, so sites often show a challenge after a certain depth or after a burst of fast page loads. When a page returns a challenge instead of results, pause that list, solve the challenge (for a checkbox widget, a reCAPTCHA v2 task usually returns under 9 seconds), retry the same page and continue. Spacing requests and keeping a steady concurrency level per site reduces how often this happens.
Common questions
Which pagination style is easiest to scrape?
Page numbers, because you can generate every URL up front and fetch them in parallel. Cursor lists must be read one step at a time.
Why do I get duplicate items across pages?
Items were added or removed while you crawled, so positions shifted. Deduplicate on a stable ID instead of on page position.
How do I scrape an infinite scroll page without a browser?
Find the JSON request the page makes while you scroll and call it directly with the same page or cursor parameter.
Why does a CAPTCHA appear only on later pages?
Deep paging is unusual for people, so many sites raise checks after a certain depth or speed. Slow down and solve the challenge when it appears.
Should I limit how many pages a job can request?
Yes. A per list ceiling protects you from end detection bugs that would otherwise loop until the job is killed.
Keep reading
- Hidden API scrapingReading the JSON endpoints a page quietly calls, so you collect clean data without parsing the rendered HTML.
- Request queueThe list of URLs a crawler still has to visit, with retries, priorities and deduplication built into how it is stored.
- How do I scrape pages with infinite scroll?Call the JSON endpoint the page uses to load more items, or scroll in a browser until no new items arrive.
- Web crawlingWeb crawling discovers pages by following links outward from seed URLs, managed through a crawl frontier that decides what to fetch next.