Paginating Through Pages

The paginate function navigates through paginated listings by clicking a next-page button or following a URL.

Features

  • Handles Pagination: Clicks "Next" buttons or follows pagination URLs.

  • Auto-Detects Next Page: Extracts next-page elements dynamically.

  • Supports Custom Timeout: Defines waiting time for navigation.

Parameters

  • get_next_page_element (Callable[..., Awaitable[URL | ElementHandle | None]]): Function returning the next page URL or button.

  • timeout (int): Time in milliseconds to wait before continuing.

Returns

  • None: Navigates and processes paginated pages.

Usage

async def get_next():
    return await sdk.page.query_selector("a.next")

await sdk.paginate(get_next)