Skip to main content

How to scrape an infinite scroll page from its data request

Find the request a scrolling page sends for each new batch, call it yourself page by page, and check it against the batch the page loaded before any scroll.

From our run on
  1. page=2   status 200   1.8 seconds
  2. {"has_next":true,"page":2,"quotes":[
  3. page=10  status 200   1.4 seconds
  4. {"has_next":false,"page":10,"quotes":[
How-to 14 min read

To scrape an infinite scroll page, find the request the page sends for its next batch of items as you near the bottom, then call that request yourself, moving its page number, offset or cursor one step at a time until the response says there is nothing left. Scroll a real browser only when you cannot find that request or cannot repeat it.

A scrolling list looks like one long page, but on many sites the server does not send it that way. It sends a short document and a script, and the script asks for the items a batch at a time. Once you know the address the script calls, you can skip the scrolling and read the batches directly. Each answer usually arrives as data, often with a field that says whether another batch exists. On the practice site below that is a page number and a has_next flag. On your site it may be something else, so use what the network panel shows you.

Why the first fetch comes back short

MDN's page on the Intersection Observer API names infinite scroll as one of the jobs that API exists for, describing sites "where more and more content is loaded and rendered as you scroll, so that the user doesn't have to flip through pages." The words that matter for a scraper are loaded and rendered. The items are not in the first response. They arrive later, from a second request, and a script turns them into markup.

A plain HTTP fetch of such a page gets the shell and nothing else. A browser that loads the page gets the first batch, because the script runs once on load. Neither gets the rest unless something scrolls. The run further down shows that gap on a practice site.

The same MDN page describes the old way sites watched the scroll position, where "As the user scrolls the page, these intersection detection routines are firing constantly during the scroll handling code". Whichever way the page watches, the result for you is the same. Some event near the bottom of the list fires a request, and that request is what you want.

This clip finds the paged request behind a list that loads on scroll.

A scrolling list is a paged request. 54 s, no sound. The words are on screen, and the captions button shows them at your own text size.
Read the transcript

A scrolling list is a paged request. A practice page that loads quotes as you scroll, read from its own script.

A plain fetch held 0 quotes. The page's own script asks for them. quotes.toscrape.com/scroll, in its HTML: <div class="quotes"></div> $.get('/api/quotes', {page: page}).done(function(data) { hasNextPage = data.has_next; 0: quotes in a plain fetch. 10: quotes a browser loaded, no scroll.

Each call returns one batch and a flag that says if more follow. page=1: has_next true. page=2: has_next true. pages 3 to 9: not fetched. page=10: has_next false. page=11: empty list, status 200.

7 records of page 1 match the quotes a browser loaded, in order. 7 records match the loaded page, in order. 1 breaks off in the saved copy. 2 not in the saved copy. 10: quotes on the page before any scroll.

Read the flag in each answer. Stop when it says false. After each call: read has_next. true: Ask for the next page. false: Stop: that was the last batch. This run: false.

Read the full page. The page is at spider.cloud/learn/infinite-scroll.

Find the request in the network panel

The browser's developer tools show every request a page makes. Chrome's guide to the Network panel says "Each row of the Network Log represents a resource", listed in the order they happened. Open the panel before you scroll, so nothing is missed.

  1. Load the page with the Network panel open. The guide notes that the panel is empty until you reload, because DevTools records only while it is open.
  2. Scroll to the bottom of the list and watch for a new row at the end of the log. The guide shows the same thing with a button: "Clicking the Get Data button caused the page to request this file." A scroll that loads more items does the same.
  3. Narrow the log. The guide says "The Filter input box supports many different types of filtering", so typing part of a path such as api or page will usually leave a handful of rows.
  4. Click the new row and open its Response tab. If the response holds the items you just saw appear, you have found the request. Note its full address, its method and any query parameters.
  5. Check the Initiator column. The guide defines it as "What caused a resource to be requested", and following it takes you to the script line that sent the request. That line tells you which parameter changes from one batch to the next.

Scroll once more and compare the second request with the first. Usually one value moves: a page number, an offset, or a cursor the previous response handed back. That value and the field that says whether more remain are all your loop needs.

The practice page and its script

Quotes to Scrape is a site made for scraping practice, and its /scroll page loads quotes as you scroll. A plain HTTP fetch of that page, with no browser, returned this text and no quotes at all:

Quotes to Scrape
Quotes to Scrape Login

The raw HTML of the same fetch shows why. The list is an empty div, and a short script fills it. These lines are cut from that response, unchanged, with each gap marked by a line holding only [lines not shown]:

        <div class="quotes"></div>
[lines not shown]
        var page = 1, tag = null, hasNextPage = true;
[lines not shown]
            $.get('/api/quotes', {page: page}).done(function(data) {
                appendQuotes(data.quotes);
                hasNextPage = data.has_next;
[lines not shown]
        updatePage(page);
        $(window).on('scroll', function(){

On load, the script asks /api/quotes for page 1 and appends what comes back. It keeps the has_next field of each answer in hasNextPage, and it listens for scroll events. Our copy of the response ends inside that scroll handler, but the page number and the flag are already in view. You can read the paging rule straight from the source here. On a site that bundles and minifies its scripts, the network panel is the faster way to the same answer.

The run: the page before any scroll, against the request behind it

The run compares two fetches made on 2026-11-21, about two minutes apart. One calls the page's own data request for page 1. The other loads /scroll in a browser and keeps the text the whole page held once it had loaded, with no scrolling. That text covers the full loaded page, not one screen of it, so it shows which quotes the first batch put on the page and says nothing about which of them fit in the window. Both need an API key in SPIDER_API_KEY. Here is the data request, sent as a plain HTTP fetch. return_format set to raw keeps the body as the server sent it, which here is JSON, and user_agent names the client to the site.

curl -s https://api.spider.cloud/scrape \
  -H "Authorization: Bearer $SPIDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://quotes.toscrape.com/api/quotes?page=1", "request": "http", "return_format": "raw", "user_agent": "examplebot/1.0 (+https://example.com/bot; bot@example.com)"}'

It went out at 00:07 UTC on 2026-11-21 and came back with status 200 in 1.4 seconds. Our saved copy of its content field is below. We put a line break before each record so they can be read one by one, and changed nothing else. The copy stops partway through the eighth record, so the last line is unfinished:

{"has_next":true,"page":1,"quotes":[
{"author":{"goodreads_link":"/author/show/9810.Albert_Einstein","name":"Albert Einstein","slug":"Albert-Einstein"},"tags":["change","deep-thoughts","thinking","world"],"text":"\u201cThe world as we have created it is a process of our thinking. It cannot be changed without changing our thinking.\u201d"},
{"author":{"goodreads_link":"/author/show/1077326.J_K_Rowling","name":"J.K. Rowling","slug":"J-K-Rowling"},"tags":["abilities","choices"],"text":"\u201cIt is our choices, Harry, that show what we truly are, far more than our abilities.\u201d"},
{"author":{"goodreads_link":"/author/show/9810.Albert_Einstein","name":"Albert Einstein","slug":"Albert-Einstein"},"tags":["inspirational","life","live","miracle","miracles"],"text":"\u201cThere are only two ways to live your life. One is as though nothing is a miracle. The other is as though everything is a miracle.\u201d"},
{"author":{"goodreads_link":"/author/show/1265.Jane_Austen","name":"Jane Austen","slug":"Jane-Austen"},"tags":["aliteracy","books","classic","humor"],"text":"\u201cThe person, be it gentleman or lady, who has not pleasure in a good novel, must be intolerably stupid.\u201d"},
{"author":{"goodreads_link":"/author/show/82952.Marilyn_Monroe","name":"Marilyn Monroe","slug":"Marilyn-Monroe"},"tags":["be-yourself","inspirational"],"text":"\u201cImperfection is beauty, madness is genius and it's better to be absolutely ridiculous than absolutely boring.\u201d"},
{"author":{"goodreads_link":"/author/show/9810.Albert_Einstein","name":"Albert Einstein","slug":"Albert-Einstein"},"tags":["adulthood","success","value"],"text":"\u201cTry not to become a man of success. Rather become a man of value.\u201d"},
{"author":{"goodreads_link":"/author/show/7617.Andr_Gide","name":"Andr\u00e9 Gide","slug":"Andre-Gide"},"tags":["life","love"],"text":"\u201cIt is better to be hated for what you are than to be loved for what you are not.\u201d"},
{"author":{"goodreads_link":"/author/show/3091287.Thomas_A

For the other side, the browser fetch of the page itself. This is the body as it was sent:

curl -s https://api.spider.cloud/scrape \
  -H "Authorization: Bearer $SPIDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://quotes.toscrape.com/scroll", "request": "browser", "return_format": "text", "user_agent": "examplebot/1.0 (+https://example.com/bot; bot@example.com)"}'

That fetch went out at 00:08 UTC, came back with status 200 in 3.3 seconds, and its content field held ten quotes. Here is the field in full, printed as a JSON string so the curly quote marks show as the same \u201c and \u201d escapes the data request uses:

"Quotes to Scrape\nQuotes to Scrape Login \u201cThe world as we have created it is a process of our thinking. It cannot be changed without changing our thinking.\u201d by Albert Einstein Tags: change deep-thoughts thinking world \u201cIt is our choices, Harry, that show what we truly are, far more than our abilities.\u201d by J.K. Rowling Tags: abilities choices \u201cThere are only two ways to live your life. One is as though nothing is a miracle. The other is as though everything is a miracle.\u201d by Albert Einstein Tags: inspirational life live miracle miracles \u201cThe person, be it gentleman or lady, who has not pleasure in a good novel, must be intolerably stupid.\u201d by Jane Austen Tags: aliteracy books classic humor \u201cImperfection is beauty, madness is genius and it's better to be absolutely ridiculous than absolutely boring.\u201d by Marilyn Monroe Tags: be-yourself inspirational \u201cTry not to become a man of success. Rather become a man of value.\u201d by Albert Einstein Tags: adulthood success value \u201cIt is better to be hated for what you are than to be loved for what you are not.\u201dby Andr\u00e9 Gide Tags: life love \u201cI have not failed. I've just found 10,000 ways that won't work.\u201d by Thomas A. Edison Tags: edison failure inspirational paraphrased \u201cA woman is like a tea bag; you never know how strong it is until it's in hot water.\u201d by Eleanor Roosevelt Tags: misattributed-eleanor-roosevelt \u201cA day without sunshine is like, you know, night.\u201d by Steve Martin Tags: humor obvious simile"

This side needs the browser. Sent at 00:25 UTC with request set to smart and a wait_for on the .quote selector, the same page came back with status 200 and the same two lines as the plain fetch, Quotes to Scrape and Quotes to Scrape Login, and no quotes.

Read the two outputs side by side and the first seven records of the data request match the first seven quotes in the browser text: the same words, the same authors and the same tags, in the same order. The eighth record breaks off at the author link /author/show/3091287.Thomas_A, and the eighth quote in the browser text is by Thomas A. Edison. Our copy stops before that record's text, so the run cannot show the two match, and records nine and ten are not in our copy at all. What the run confirms is that the first seven quotes on the loaded page came, word for word and in order, from page 1 of the data request. To learn which quotes a reader sees before scrolling, you would need a screenshot at a stated window size, and this run did not take one.

The loaded page held ten quotes and stopped there. Three more calls with the same body as the data request, changing only the page number, show where the rest lives. For pages 2 and 10, each block starts at the beginning of the saved content field, with the same added line breaks, and a line holding only [remaining records not shown] marks where we stopped copying.

page=2   status 200   1.8 seconds
{"has_next":true,"page":2,"quotes":[
{"author":{"goodreads_link":"/author/show/82952.Marilyn_Monroe","name":"Marilyn Monroe","slug":"Marilyn-Monroe"},"tags":["friends","heartbreak","inspirational","life","love","sisters"],"text":"\u201cThis life is what you make it. No matter what, you're going to mess up sometimes, it's a universal truth. But the good part is you get to decide how you're going to mess it up. Girls will be your friends - they'll act like it anyway. But just remember, some come, some go. The ones that stay with you through everything - they're your true best friends. Don't let go of them. Also remember, sisters make the best friends in the world. As for lovers, well, they'll come and go too. And baby, I hate to say it, most of them - actually pretty much all of them are going to break your heart, but you can't give up because if you give up, you'll never find your soulmate. You'll never find that half who makes you whole and that goes for everything. Just because you fail once, doesn't mean you're gonna fail at everything. Keep trying, hold on, and always, always, always believe in yourself, because if you don't, then who will, sweetie? So keep your head high, keep your chin up, and most importantly, keep smiling, because life's a beautiful thing and there's so much to smile about.\u201d"},
{"author":{"goodreads_link":"/author/show/1077326.J_K_Rowling","name":"J.K. Rowling","slug":"J-K-Rowling"},"tags":["courage","friends"],"text":"\u201cIt takes a great deal of bravery to stand up to our enemies, but just as much to stand up to our friends.\u201d"},
[remaining records not shown]

page=10  status 200   1.4 seconds
{"has_next":false,"page":10,"quotes":[
{"author":{"goodreads_link":"/author/show/1077326.J_K_Rowling","name":"J.K. Rowling","slug":"J-K-Rowling"},"tags":["truth"],"text":"\u201cThe truth.\" Dumbledore sighed. \"It is a beautiful and terrible thing, and should therefore be treated with great caution.\u201d"},
[remaining records not shown]

Neither of the page 2 records shown is in the browser text. Page 10 still has quotes, and its has_next is false, which marks the end of the list. We did not fetch pages 3 to 9. One call past the end, page=11, came back in full like this:

{"has_next":false,"page":11,"quotes":[],"tag":null,"top_ten_tags":[["love",14],["inspirational",13],["life",13],["humor",12],["books",11],["reading",7],["friendship",5],["friends",4],["truth",4],["simile",3]]}

The status was 200 again. The list is empty and has_next is false, so a loop that stops on has_next would never have sent this call. A loop that counts pages and waits for an error code would keep going.

Write the loop

With the request found, the scraper is short. Start at the first page or with no cursor, fetch, keep the items, and read the field that says whether more remain. Stop when it says no, when a page comes back with no items, or when you reach a page cap you set yourself. Our sibling page on following a paginated list covers those stop signals in detail, and they carry over unchanged.

Put a pause between calls. On the page, a reader has to get through one batch before the script asks for the next, and a loop that sends them back to back asks far more often than that. The request rate page shows how to pick a pace and what to do when a site asks you to slow down. Check the data path against the site's robots.txt as well, because a site may disallow its API paths while allowing the page that calls them.

Some data requests will not repeat outside the page. They may need a cookie set on load, a token printed in the HTML, or a header the script adds. Copy what the browser sent from the Headers tab of that row, one value at a time, until the call works, and stop at what the page itself would send. If the request needs a login, read the site's terms before you go further, and ask for access when the terms say no.

When you cannot find the request

Some pages build items from data already in the HTML, and some send requests that change shape every time. For those, let a browser do the scrolling. The API's scroll field scrolls the page as new content loads for up to the number of milliseconds you give it, and it needs a browser request. The browser fetch in the run above set no scroll, and its text stopped at the first batch. Check the item count from a scrolled render against what you saw by hand, since a scroll that ends too early looks like a short list.

A list that loads on scroll is one of several ways a page keeps its items out of the first response, and the web scraping guide is where to go for fetching and parsing in general. Other pages in this section are on the learning center index.

Do this, avoid this

Do this

  • Open the Network panel before you scroll, then scroll once and find the row that returned the new items.
  • Scroll a second time and note which parameter changed between the two requests.
  • Stop on the response field that says no more items remain, such as has_next or an empty cursor.
  • Match the records from your first call, text and order, against the batch the page loaded before you scrolled.

Avoid this

  • Taking the empty list in a plain fetch of the shell as the whole page.
  • Scrolling a browser for a list whose data request you can call directly.
  • Sending cookies, tokens or headers the page itself would not send.
  • Paging past the end on a page counter alone without checking the response for an empty list.

The same steps on a list you choose

Load the scrolling list you want with the Network panel open and scroll once. Copy the address of the new row into the url of the data request above, with the method and the first page, offset or cursor value you saw in the panel. If its records match, in the same order, the batch the page loaded before you scrolled, move that value one step, call it again after a pause, and stop when the response says nothing is left. On Quotes to Scrape the step is page=2 and the stop is has_next set to false. Your site will have its own names for both.

Sources

  1. MDN Web Docs, Intersection Observer API Read
  2. Chrome for Developers, Inspect network activity Read

Run this on a page you care about

The playground sends the request this page describes and shows you the response. Keyless runs work without an account and are rate limited.