Reference

Core Functions

The main screenshot and PDF capture API

webshot()

Take a screenshot or PDF of a web page.

from_html()

Take a screenshot or PDF from an HTML string.

close()

Explicitly close the module-level browser and CDP connection.

Browser Management

Chrome process lifecycle and discovery

Chrome

Manages a headless Chrome browser process.

find_chrome()

Locate the Chrome or Chromium binary on the system.

Session

Low-level browser tab and navigation control

Session

A CDP session representing a single browser tab.

Errors

Exception hierarchy for error handling

NokapError

Base exception for all nokap errors.

CDPError

Error returned by the Chrome DevTools Protocol.

ChromeNotFoundError

Raised when Chrome/Chromium cannot be found on the system.

ChromeStartError

Raised when Chrome fails to start or report its DevTools URL.

NavigationError

Raised when page navigation fails.

PageLoadTimeout

Raised when a page does not finish loading within the timeout.

SelectorError

Raised when a CSS selector matches no elements.

Types

Type definitions for configuration

PaperSize()

Special typing form to define literal types (a.k.a. value types).