How to scrape infinite scroll pages: window scroll, inner panels and load more buttons
How to scrape infinite scroll pages: look for pagination first, then use scroll_to_bottom on the window or an inner panel, bound it, and test the rendered DOM.
- Published
- Reading time
- 9 min read
- By
- ExtractHub team
- infinite scroll
- browser actions
- JavaScript rendering
- web scraping
- tutorial
On this page
An infinite scroll page shows the first batch of results and loads the next one only when you get near the end. A plain HTTP fetch sees the first batch and nothing else. If you want to scrape infinite scroll pages, something has to do the scrolling: a browser that renders the page, scrolls the right element, waits for the new items and stops at a sensible point.
This guide shows how to do that with ExtractHub browser actions, how to tell a window scroll from an inner panel, how to bound the scroll, and when you should not scroll at all. The general case for rendering is covered in how to scrape JavaScript rendered pages; this post goes deeper on scrolling.
Before you scroll: look for pages or an API
Scrolling is the most expensive and slowest way to get more items, so rule out the cheaper ones first.
- Numbered pages. Many infinite scroll lists also have plain page URLs such as
?page=2, sometimes linked at the bottom of the raw HTML or in a<link rel="next">tag. Search the raw HTML (curlor view-source) forpage=orrel="next". If they exist, build one extractor for one page and fetch every page URL. That is a plain fetch, no browser, and the Batch API runs a list of page URLs in one call. - A paged background API. Open the browser’s network tab and scroll. If each scroll fires a request like
/api/items?offset=40, call that URL yourself withsourceType: "json". You get the API’s own field names and no selectors to break. - Embedded JSON. The first batch is often in a
<script>block as JSON (see scrape embedded JSON). It does not give you the next batches, but it tells you whether the first page alone is enough.
Scroll when none of these work: the next items exist only after the page’s own JavaScript asked for them, and the request needs browser cookies or tokens you cannot reproduce.
How to scrape infinite scroll pages with scroll_to_bottom
Browser actions are steps the headless browser runs after the page loads and before the HTML is taken. They need renderJavascript: true (and the proxy; JavaScript rendering always goes through it). The scroll-related ones:
| Action | Keys | What it does |
|---|---|---|
wait_for_element | selector, timeout_s | Waits until an element exists |
scroll_to_bottom | timeout_s, optional selector (+ max_scrolls, pause_s, stop_when) | Scrolls the window, or one element, towards its end |
scroll | x, y (pixels), optional selector | Scrolls by an amount, relative to where the page or element is now |
click | selector | Clicks, for example a “Load more” button |
wait | wait_time_s | A fixed pause |
Every action takes on_error: "error" (the default, the request fails) or "skip" (carry on). Selectors are objects, { "type": "css", "value": "..." }; a plain string is a validation error.
Here is an illustrative example for an imaginary shop whose search page loads more products as the window scrolls (the selectors are made up, not taken from a real site):
{
"name": "Example shop - search results (infinite scroll)",
"url": "https://shop.example.com/search?q=desk+lamp",
"useProxy": true,
"renderJavascript": true,
"browserActions": [
{ "type": "wait_for_element", "selector": { "type": "css", "value": "#results article.product" }, "timeout_s": 10 },
{ "type": "click", "selector": { "type": "css", "value": "#cookie-accept" }, "on_error": "skip" },
{ "type": "scroll_to_bottom", "timeout_s": 10, "on_error": "skip" }
],
"extractorConfig": {
"fields": [
{
"name": "products",
"selector": "#results article.product",
"isArray": true,
"extract": "innerHTML",
"required": true,
"includePosition": true,
"subExtractor": {
"fields": [
{ "name": "name", "selector": "h3", "extract": "textContent", "transforms": ["trim"], "required": true },
{ "name": "url", "selector": "a[href]", "extract": "attributeValue", "attributeName": "href", "transforms": ["toAbsoluteUrl"] },
{ "name": "price", "selector": ".price", "extract": "textContent", "transforms": ["extractPrice"] }
]
}
},
{ "name": "itemCount", "selector": "#results article.product", "extract": "count" }
]
}
}
Three details in this definition matter for infinite scroll:
- Wait first, then scroll.
wait_for_elementmakes sure the first batch is there. Scrolling an empty shell does nothing useful. on_error: "skip"on optional steps. The cookie banner is not always shown, and a page with only one batch of results has nothing to scroll. Neither should fail the request.- A
countfield.itemCountreturns the number of matched cards. Compare it across a few test calls: if it never grows past the first batch, the scroll is not loading anything (often because the wrong element scrolls, see the next section).
Mark the list required too. If the page does not load at all, the request fails with required_fields_missing instead of returning [], which looks like “no results”. Required fields explains the rule.
Scroll the window or an inner results panel
Without a selector, scroll_to_bottom and scroll move the page window. That fits pages where the whole document grows as you scroll.
Many layouts do something else: the window stays still and only an inner element scrolls. Map-style results panels, chat and comment threads and side lists work this way. Scrolling the window there does nothing, and you keep getting the first batch. In the browser’s developer tools, find the element that has the scrollbar (it usually has overflow-y: auto or scroll and a fixed height) and give it as the selector:
{
"type": "scroll_to_bottom",
"selector": { "type": "css", "value": "#results-panel" },
"timeout_s": 20,
"max_scrolls": 8,
"pause_s": 2,
"stop_when": { "type": "css", "value": "#results-panel .end-of-list" }
}
(Illustrative example: the panel and the end-of-list marker are made up.)
With a selector, scroll_to_bottom runs a loop. It scrolls the element to its end, waits pause_s seconds for new content, and repeats. It stops at the first of these:
- the element did not grow after a pause (nothing more loaded);
max_scrollsrounds are done (1 to 50, default 10);- the
stop_whenelement exists, such as an “end of results” message; timeout_sruns out (at most 30 seconds with a selector).
pause_s takes 0.5 to 5 seconds (default 1.5). max_scrolls, pause_s and stop_when only exist on an element scroll: on a window scroll_to_bottom they are a validation error. Element selectors are CSS or XPath; text selectors are not accepted on scroll actions. If the panel is not on the page, on_error decides: "skip" does nothing, "error" fails the action.
scroll with a selector scrolls that element by x / y pixels from where it is now. Use it when a list loads on any movement rather than at the very end, or when you only need one or two more batches.
Bound the scroll: stop conditions and time
An infinite scroll page is, by design, never done. Decide in advance how many items one call should return, and make the scroll stop there:
stop_whenfor a real end. If the site prints “No more results” or shows a footer only after the last batch, that element is the cleanest stop condition.max_scrollsfor a fixed amount. If each scroll loads roughly one batch,max_scrollsis effectively “how many more batches”. Count the batch size on the live site rather than assuming one.timeout_sas the safety net. Keep it short. Every second of scrolling adds to the request time, and long chains of waits and scrolls risk running out of time before the HTML is taken.
A useful habit: one call returns a bounded slice of the list, and you get coverage from more URLs (search terms, categories, filters) instead of from one endless scroll. Smaller slices are faster, easier to retry, and a failure costs you one slice.
Load more buttons and virtualised lists
Some lists use a “Load more” button instead of scrolling. Click it and wait, as many times as you need:
"browserActions": [
{ "type": "wait_for_element", "selector": { "type": "css", "value": "#results .item" }, "timeout_s": 10 },
{ "type": "click", "selector": { "type": "css", "value": "button.load-more" }, "on_error": "skip" },
{ "type": "wait", "wait_time_s": 2, "on_error": "skip" },
{ "type": "click", "selector": { "type": "css", "value": "button.load-more" }, "on_error": "skip" },
{ "type": "wait", "wait_time_s": 2, "on_error": "skip" }
]
on_error: "skip" on the clicks means a list that runs out early still returns what it loaded. A button that only shows up after a scroll needs a scroll_to_bottom before the click.
Watch out for virtualised lists. Some front ends keep only the visible rows in the DOM and remove the ones that scrolled away. After a long scroll the HTML then holds the last items, not all of them. If itemCount stays flat while the scroll clearly moves, look for the background API from the first section: it returns every batch, while the DOM only ever shows a window of it.
Element scroll is not available on every site
Scrolling inside an element cannot run for every target site. When it cannot run for a request, the call fails before any page is fetched, with HTTP 422 and the code browser_action_unavailable:
{
"success": false,
"error": "Scrolling inside an element is not available for this site right now. Remove the selector from scroll / scroll_to_bottom, or try again later.",
"errors": [
{
"code": "browser_action_unavailable",
"message": "Scrolling inside an element is not available for this site right now. Remove the selector from scroll / scroll_to_bottom, or try again later."
}
],
"requestId": "..."
}
It is not charged, since nothing was fetched. Batch items and pipeline steps treat it as permanent and do not retry it.
You can see this coming. The MCP tools validate_extractor_config, create_extractor, update_extractor and the release_extractor plan return the warning element_scroll_unavailable, with the path of the first element scroll (for example browserActions[2].selector), when the site cannot run it at that moment. Studio shows the same notice under the selector field. It is a warning, not an error: saving and releasing still work, because availability can change. A window scroll (no selector) is the fallback.
What scrolling costs
Any browser action puts the extractor on the JavaScript tier, the highest of the three per-URL tiers (direct, proxy, JavaScript). The price is per call: a longer scroll does not cost more, but every call is billed at that tier, which is why numbered pages or a paged API fetched without a browser are worth checking first. A call that fails after the page was fetched is charged like any other failure after a fetch; the error body says charged: true. Prices are in the pricing section.
Validate on the scrolled DOM, then test live
An extractor that scrolls has to be checked against the page after the scroll. A sample saved from a fresh page load has only the first batch and tells you nothing about the scroll. Save the rendered DOM with the same steps: a Playwright script that waits for the first card, scrolls the same element and then writes page.content() to a file. Never save it from a logged-in browser profile.
With the ExtractHub MCP server connected, an agent can validate the definition on that file without fetching or credit, save it as a private draft, and run one live call on @draft with the real browser actions:
curl -G "https://api.extracthub.io/api/extractor/extract" \
-H "X-API-Key: $EXTRACTHUB_API_KEY" \
--data-urlencode "extractor_id=@you/example-shop-search@draft" \
--data-urlencode "target_url=https://shop.example.com/search?q=desk+lamp"
That live call is billed at the JavaScript tier. Run it two or three times and compare itemCount: it should be above the first batch and roughly stable. The extractor builder skill follows the same order (sample, validate, draft, live test, release) when you ask an agent to build the extractor for you.
Checklist to scrape infinite scroll pages
- Check for
?page=URLs,rel="next", a paged background API or embedded JSON before you scroll. renderJavascript: true, thenwait_for_elementon the first item, then the scroll.- Window grows:
scroll_to_bottomwithout a selector. Inner panel scrolls:scroll_to_bottomwith that panel asselector. - Bound it with
stop_when,max_scrollsand a shorttimeout_s(at most 30 with a selector). on_error: "skip"on cookie banners and optional clicks.- Add a
countfield and mark the listrequired. - Watch for
element_scroll_unavailablewarnings; a window scroll is the fallback. - Validate on a sample saved after the scroll, then run a live
@drafttest before you release.
FAQ
How do you scrape a page with infinite scroll?
Render the page in a headless browser and add a scroll_to_bottom browser action before the HTML is taken, then extract the list as usual. If the site also has numbered page URLs or a paged background API, fetching those directly is usually simpler and runs on a cheaper tier.
Why does my scraper only get the first items of an infinite scroll page?
Either nothing scrolled, or the wrong thing scrolled. Many sites load more items when an inner results panel reaches its end while the window stays still; give that panel as the selector of scroll_to_bottom so the panel itself is scrolled.
Does it cost more to scrape infinite scroll pages?
No. Any browser action puts the extractor on the JavaScript tier, and the price is per call: a longer scroll does not cost more, but every call is billed at that tier. Prices are on the pricing section of the home page.
What does the browser_action_unavailable error mean?
Scrolling inside an element cannot run for that site right now. The call fails before any page is fetched with HTTP 422 and is not charged; remove the selector to scroll the window instead, or retry later.
Related
- Build a job listings scraper: list pages, JobPosting JSON and dedupe by URL: Build a job listings scraper that returns structured JSON: job URLs from list pages, JobPosting fields and ISO dates from each job page, and dedupe by URL.
- Build a price monitoring scraper: product fields, daily runs and change detection: Build a price monitoring scraper: a product extractor with typed prices, daily batch or scheduled runs, a signed webhook and change detection in your code.
- Use ready-made web scrapers instead of writing one: find, check and pin a public extractor: Use ready-made web scrapers instead of writing one: find a public extractor, read its fields, price tier and health, pin a version and call it with your key.
- Agent skill: install the extractor builder skill for Claude Code
- MCP server: connect Claude Code, Cursor or any MCP client
- API reference: realtime extract, async jobs and the Batch API
- Web scraper catalog: public extractors you can call today