Official Python SDK for Capture - Screenshot and content extraction API.
pip install capture-sdkfrom capture import Capture
client = Capture("your-api-key", "your-api-secret")
image_url = client.build_image_url("https://example.com")
print(image_url)- 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
from capture import Capture
client = Capture("your-api-key", "your-api-secret")
client_with_edge = Capture("your-api-key", "your-api-secret", {"useEdge": True})The SDK provides URL builders for each capture type:
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_url = client.build_pdf_url("https://example.com")
pdf_url_with_options = client.build_pdf_url(
"https://example.com",
{
"full": True,
"delay": 1
}
)content_url = client.build_content_url("https://example.com")metadata_url = client.build_metadata_url("https://example.com")animated_url = client.build_animated_url("https://example.com")The SDK provides async methods to fetch data directly:
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())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())async def main():
content = await client.fetch_content("https://example.com")
print(content["html"])
print(content["textContent"])
asyncio.run(main())async def main():
metadata = await client.fetch_metadata("https://example.com")
print(metadata["metadata"])
asyncio.run(main())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())useEdge(bool): Use edge.capture.page instead of cdn.capture.page for faster response times
The SDK supports two base URLs:
- CDN:
https://cdn.capture.page(default) - Edge:
https://edge.capture.page(whenuseEdge: True)
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)MIT
For support, please visit capture.page or open an issue on GitHub.