> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Handle infinite scrolling

## Recipe

This recipe shows how to scrape data from infinite scroll pages using [`scrollToLoadContent`](/automation-sdks/intuned-sdk/typescript/helpers/functions/scrollToLoadContent) (TypeScript) or [`scroll_to_load_content`](/automation-sdks/intuned-sdk/python/helpers/functions/scroll_to_load_content) (Python).

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  import { BrowserContext, Page } from "playwright";
  import { scrollToLoadContent } from "@intuned/browser";

  interface Product {
    name: string;
    price: string;
  }

  // Extract products from the page
  async function extractProducts(page: Page): Promise<Product[]> {
    const results: Product[] = [];
    const productCards = page.locator(".product-item");
    const count = await productCards.count();

    for (let i = 0; i < count; i++) {
      const card = productCards.nth(i);
      const name = await card.locator(".product-name").textContent();
      const price = await card.locator(".product-price").textContent();

      if (name && price) {
        results.push({
          name: name.trim(),
          price: price.trim(),
        });
      }
    }

    return results;
  }

  export default async function handler(
    params: { maxScrolls?: number },
    page: Page,
    context: BrowserContext
  ) {
    await page.goto("https://www.scrapingcourse.com/infinite-scrolling");

    // Scroll to load all content
    await scrollToLoadContent({
      source: page,
      maxScrolls: params.maxScrolls ?? 50,
    });

    // Extract all products after content is loaded
    const products = await extractProducts(page);
    console.log(`Extracted ${products.length} products`);

    return products;
  }
  ```

  ```python Python theme={null}
  from playwright.async_api import Page
  from intuned_browser import scroll_to_load_content
  from typing import Any, Dict, List, Optional


  async def extract_products(page: Page) -> List[Dict[str, str]]:
      """Extract products from the page."""
      results = []
      product_cards = page.locator(".product-item")
      count = await product_cards.count()

      for i in range(count):
          card = product_cards.nth(i)
          name = await card.locator(".product-name").text_content()
          price = await card.locator(".product-price").text_content()

          if name and price:
              results.append({
                  "name": name.strip(),
                  "price": price.strip(),
              })

      return results


  async def automation(page: Page, params: Optional[Dict] = None, **_kwargs):
      await page.goto("https://www.scrapingcourse.com/infinite-scrolling")

      max_scrolls = params.get("max_scrolls", 50) if params else 50

      # Scroll to load all content
      await scroll_to_load_content(
          source=page,
          max_scrolls=max_scrolls,
      )

      # Extract all products after content is loaded
      products = await extract_products(page)
      print(f"Extracted {len(products)} products")

      return products
  ```
</CodeGroup>

## Related SDK methods

<CardGroup cols={2}>
  <Card title="scrollToLoadContent (TypeScript)" icon="js" href="/automation-sdks/intuned-sdk/typescript/helpers/functions/scrollToLoadContent">
    TypeScript SDK helper for scrolling to load content
  </Card>

  <Card title="scroll_to_load_content (Python)" icon="python" href="/automation-sdks/intuned-sdk/python/helpers/functions/scroll_to_load_content">
    Python SDK helper for scrolling to load content
  </Card>

  <Card title="Cookbook (Python)" icon="github" href="https://github.com/Intuned/cookbook/tree/main/python-examples/quick-recipes">
    Python quick recipes in the Intuned Cookbook
  </Card>

  <Card title="Cookbook (TypeScript)" icon="github" href="https://github.com/Intuned/cookbook/tree/main/typescript-examples/quick-recipes">
    TypeScript quick recipes in the Intuned Cookbook
  </Card>
</CardGroup>
