Capturing a PDF

The capture_pdf function captures the current web page and saves it as a PDF file.

Features

  • Generates a PDF of the Current Page: Saves the full rendered page as a PDF.

  • Supports Automatic Storage: Ensures efficient file saving.

Parameters

  • None

Returns

  • DownloadMeta: Metadata about the captured PDF file.

class DownloadMeta(TypedDict):
    url: str
    filename: str

Usage

async def scrape(
    sdk: SDK, current_url: str, context: dict[str, Any], *args: Any, **kwargs: Any
) -> None:
    pdf_metadata = await sdk.capture_pdf()
    data = {"title": download_metadata["filename"], "url": pdf_metadata["url"]}
    await sdk.save_data(data)