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.create_session({"maxTtlSeconds": 300})
    session_id = created["session"]["id"]

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

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

    await client.close_session(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.1.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.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: capture_sdk-1.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 090d598b51a56aba2cb21d2a876f82cb185ddfeba234ceda262acbb5d8919451
MD5 04775cbd7a92ae46bdeb3e7c05080ae8
BLAKE2b-256 71705f7e3e4949270feb34aca904c128c87930727d4c679b3ed6e1e5cc8a59f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: capture_sdk-1.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f45f8b7c7e49c6c4ee4904ac92e8ee5b67253363ae8f226a81577f08b89c7c91
MD5 31adfc1f0cf3a6b26e2c7b860ec92458
BLAKE2b-256 c8dd0706ae3f94c1c04c53b435291ba8ce9f3933593ff8ac1e60176c7461ff26

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