T = TypeVar("T", bound=BaseModel)ERROR_ACT_START_FAIL = 9000ERROR_ACT_TASK_FAILED = 9001ERROR_ACT_TIMEOUT = 9002ERROR_OBSERVE_FAIL = 9020ERROR_EXTRACT_FAIL = 9040ERROR_EXTRACT_START_FAIL = 9041ERROR_EXTRACT_TIMEOUT = 9042class AsyncBrowserAgent(BaseService)BrowserAgent handles browser automation and agent logic.
⚠️ Note: Currently, for agent services (including ComputerUseAgent, BrowserUseAgent, and MobileUseAgent), we do not provide services for overseas users registered with alibabacloud.com.
def __init__(self, session, browser)async def navigate(url: str) -> strNavigates a specific page to the given URL.
Arguments:
url: The URL to navigate to.
Returns:
A string indicating the result of the navigation.
async def screenshot(page=None,
full_page: bool = True,
quality: int = 80,
clip: Optional[Dict[str, float]] = None,
timeout: Optional[int] = None) -> strAsynchronously takes a screenshot of the specified page.
Arguments:
pageOptional[Page] - The Playwright Page object to take a screenshot of. If None, the agent's currently focused page will be used.full_pagebool - Whether to capture the full scrollable page.qualityint - The quality of the image (0-100), for JPEG format.clipOptional[Dict[str, float]] - An object specifying the clipping region {x, y, width, height}.timeoutOptional[int] - Custom timeout for the operation in seconds.
Returns:
str: A base64 encoded data URL of the screenshot, or an error message.
async def close() -> boolAsynchronously closes the remote browser agent session. This will terminate the browser process managed by the agent.
async def act(action_input: Union[ObserveResult, ActOptions],
page=None) -> "ActResult"Asynchronously perform an action on a web page.
Arguments:
pageOptional[Page] - The Playwright Page object to act on. If None, the agent's currently focused page will be used automatically.action_inputUnion[ObserveResult, ActOptions] - The action to perform.
Returns:
ActResult: The result of the action.
async def observe(options: ObserveOptions,
page=None) -> Tuple[bool, List[ObserveResult]]Asynchronously observe elements or state on a web page.
Arguments:
pageOptional[Page] - The Playwright Page object to observe. If None, the agent's currently focused page will be used.optionsObserveOptions - Options to configure the observation behavior.
Returns:
Tuple[bool, List[ObserveResult]]: A tuple containing a success boolean and a list of observation results.
async def extract(options: ExtractOptions, page=None) -> Tuple[bool, T]Asynchronously extract information from a web page.
Arguments:
pageOptional[Page] - The Playwright Page object to extract from. If None, the agent's currently focused page will be used.optionsExtractOptions - Options to configure the extraction, including schema.
Returns:
Tuple[bool, T]: A tuple containing a success boolean and the extracted data as a Pydantic model instance, or None on failure.
Documentation generated automatically from source code using pydoc-markdown.