Skip to main content

Python SDK for Capture - Screenshot and content extraction API

Project description

Capture Python SDK

Official Python SDK for Capture - Screenshot and content extraction API.

Installation

pip install capture-sdk

Quick Start

from capture import Capture

client = Capture("your-api-key", "your-api-secret")

image_url = client.build_image_url("https://example.com")
print(image_url)

Features

  • Screenshot Capture: Capture full-page or viewport screenshots as PNG/JPG
  • PDF Generation: Convert web pages to PDF documents
  • Content Extraction: Extract HTML and text content from web pages
  • Metadata Extraction: Get page metadata (title, description, og tags, etc.)
  • Animated GIFs: Create animated GIFs of page interactions
  • Async Support: Built-in async/await support for all fetch methods
  • Type Hints: Full type hint support for better IDE integration

Usage

Initialize the Client

from capture import Capture

client = Capture("your-api-key", "your-api-secret")

client_with_edge = Capture("your-api-key", "your-api-secret", {"useEdge": True})

Building URLs

The SDK provides URL builders for each capture type:

Image Capture

image_url = client.build_image_url("https://example.com")

image_url_with_options = client.build_image_url(
    "https://example.com",
    {
        "full": True,
        "delay": 2,
        "width": 1920,
        "height": 1080,
        "quality": 90
    }
)

PDF Capture

pdf_url = client.build_pdf_url("https://example.com")

pdf_url_with_options = client.build_pdf_url(
    "https://example.com",
    {
        "full": True,
        "delay": 1
    }
)

Content Extraction

content_url = client.build_content_url("https://example.com")

Metadata Extraction

metadata_url = client.build_metadata_url("https://example.com")

Animated GIF

animated_url = client.build_animated_url("https://example.com")

Fetching Data (Async)

The SDK provides async methods to fetch data directly:

Fetch Image

import asyncio

async def main():
    image_data = await client.fetch_image("https://example.com")
    with open("screenshot.png", "wb") as f:
        f.write(image_data)

asyncio.run(main())

Fetch PDF

async def main():
    pdf_data = await client.fetch_pdf("https://example.com", {"full": True})
    with open("page.pdf", "wb") as f:
        f.write(pdf_data)

asyncio.run(main())

Fetch Content

async def main():
    content = await client.fetch_content("https://example.com")
    print(content["html"])
    print(content["textContent"])

asyncio.run(main())

Fetch Metadata

async def main():
    metadata = await client.fetch_metadata("https://example.com")
    print(metadata["metadata"])

asyncio.run(main())

Fetch Animated GIF

async def main():
    gif_data = await client.fetch_animated("https://example.com")
    with open("animation.gif", "wb") as f:
        f.write(gif_data)

asyncio.run(main())

Browser Sessions

async def main():
    created = await client.sessions.create({"maxTtlSeconds": 300})
    session_id = created["session"]["id"]

    await client.sessions.action(session_id, "goto", {"url": "https://example.com"})

    screenshot = await client.sessions.action(session_id, "screenshot", {
        "fullPage": True
    })

    await client.sessions.close(session_id)

asyncio.run(main())

Configuration Options

Constructor Options

  • useEdge (bool): Use edge.capture.page instead of cdn.capture.page for faster response times

API Endpoints

The SDK supports two base URLs:

  • CDN: https://cdn.capture.page (default)
  • Edge: https://edge.capture.page (when useEdge: True)

Type Hints

The SDK includes full type hint support:

from capture import Capture, RequestOptions

options: RequestOptions = {
    "full": True,
    "delay": 2,
    "width": 1920
}

client = Capture("key", "secret")
url: str = client.build_image_url("https://example.com", options)

License

MIT

Links

Support

For support, please visit capture.page or open an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

capture_sdk-1.2.0.tar.gz (146.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

capture_sdk-1.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file capture_sdk-1.2.0.tar.gz.

File metadata

  • Download URL: capture_sdk-1.2.0.tar.gz
  • Upload date:
  • Size: 146.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for capture_sdk-1.2.0.tar.gz
Algorithm Hash digest
SHA256 6326c5bda9f122dfc23953f4e3f2b13c0f5185fc80974c41b6d0faeb03b2e4a1
MD5 c5a3c4f8d7a8118565081eccd8452e18
BLAKE2b-256 2d7f8eff55c3578b7c5b99f2c7e6807f15c0837b0a70c73e948cd2f0b1d91b14

See more details on using hashes here.

File details

Details for the file capture_sdk-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: capture_sdk-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for capture_sdk-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f67810aa4f491adf52932efce8d91ffeb0b689fdbddbe034140692e95be5474
MD5 b888a203e18dd7ecc8809d15cd8ca069
BLAKE2b-256 41d55862689aaf569ef00c0f9a2082d0d2c5e79ded2ce2d04236cc39eb12e21f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page