PaginationInfo

AgentQL's Page's get_pagination_info() method returns the PaginationInfo class. PaginationInfo provides access to the pagination availability and the ability to navigate to the next page.

The following example queries for pagination information, checks if there is a next page, and navigates to the next page if possible.

pagination_example.py
python
import agentql
from playwright.sync_api import sync_playwright

with sync_playwright() as p, p.chromium.launch(headless=False) as browser:
    page = agentql.wrap(browser.new_page())
    page.goto("https://scrapeme.live/shop/page/2/")

    log.debug("Navigating to next page...")
    pagination_info = page.get_pagination_info()

    # attempt to navigate to next page
    if pagination_info.has_next_page:
        pagination_info.navigate_to_next_page()

    page.wait_for_timeout(1000)

Methods

Navigates to the next page.

Usage

pagination_example.py
python
pagination_info = page.get_pagination_info()
pagination_info.navigate_to_next_page()

Returns

tip

Always check if there is a next page before navigating to it by using the has_next_page property.


Properties

has_next_page

Detects if there is a next page.

Usage

pagination_example.py
python
pagination_info = page.get_pagination_info()
if pagination_info.has_next_page:
    pagination_info.navigate_to_next_page()

Returns