bundle.core.browser¶
Attributes¶
Classes¶
Create a collection of name/value pairs. |
|
Simplified asynchronous Playwright browser wrapper with dynamic configuration, |
Module Contents¶
- bundle.core.browser.logger¶
- bundle.core.browser.T¶
- class bundle.core.browser.BrowserType(*args, **kwds)[source]¶
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- CHROMIUM = 'chromium'¶
- FIREFOX = 'firefox'¶
- WEBKIT = 'webkit'¶
- class bundle.core.browser.Browser(/, **data: Any)[source]¶
Bases:
bundle.core.entity.EntitySimplified asynchronous Playwright browser wrapper with dynamic configuration, chainable methods, and robust error handling.
- Example Usage:
- async with Browser.chromium(headless=False) as browser:
page = await browser.new_page()
- browser_type: BrowserType = None¶
- validate_browser_type(v: str | BrowserType) BrowserType[source]¶
- classmethod chromium(headless: bool = True, **kwargs) collections.abc.AsyncIterator[Self][source]¶
- Async:
Context manager to instantiate a Chromium browser.
- classmethod firefox(headless: bool = True, **kwargs) collections.abc.AsyncIterator[Self][source]¶
- Async:
Context manager to instantiate a Firefox browser.
- classmethod webkit(headless: bool = True, **kwargs) collections.abc.AsyncIterator[Self][source]¶
- Async:
Context manager to instantiate a WebKit browser.
- async launch() Self[source]¶
Launch the specified browser type.
- Returns:
The current instance for method chaining.
- Return type:
- async new_context(*args, **kwargs) Self[source]¶
Create a new browser context.
- Returns:
The current instance for method chaining.
- Return type:
- async new_page(**context_kwargs) playwright.async_api.Page[source]¶
Create a new page within a new browser context.
- Returns:
A new Playwright Page object.
- Return type:
- async close() Self[source]¶
Close all browser contexts and the browser itself.
- Returns:
The current instance for method chaining.
- Return type:
- class Table(row_selector: str, columns: list[Browser], model: type[T])[source]¶
Bases:
bundle.core.data.Data,Generic[T]Table specification: CSS selector for rows, list of Column, and model to instantiate.
- class Column(/, **data: Any)[source]¶
Bases:
bundle.core.data.DataOne column: field name, CSS selector, parser type, and optional base_url for URL parsing.
- class Type(*args, **kwds)[source]¶
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- TEXT = 'text'¶
- INT = 'int'¶
- URL = 'url'¶