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())

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.0.0.tar.gz (144.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.0.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: capture_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 144.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.0.0.tar.gz
Algorithm Hash digest
SHA256 7ed85a4212530deea333a870a9d7b5bca11dbca123ceda45980e0bd9dd01faca
MD5 c316fff1f434d0e0f15dbb0c517baa9f
BLAKE2b-256 c8f75fbdd6afeb6e35eb28c2795130cda96650ea9a64be4b40fcf972c5aa5d95

See more details on using hashes here.

File details

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

File metadata

  • Download URL: capture_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f54c0bf61e48346ec851a7d2aa3c86338f2ec66b6a81ea726f9b4b0a10088fb5
MD5 495dac764a76161cafa7b20e508bed80
BLAKE2b-256 4f86d5439eb2b8a8f2598e9f0502b67971fd245c83f7f51f86f50059d9789496

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