techulus / capture
Official PHP SDK for Capture (capture.page). Capture screenshots, generate PDFs, extract content and metadata from web pages.
dev-main
2026-04-05 22:24 UTC
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^10.0
This package is not auto-updated.
Last update: 2026-04-06 20:40:50 UTC
README
Official PHP SDK for Capture - Screenshot and content extraction API.
Installation
composer require techulus/capture
Quick Start
use Techulus\Capture\Capture; $client = new Capture('your-api-key', 'your-api-secret'); $imageUrl = $client->buildImageUrl('https://example.com'); echo $imageUrl;
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
- Zero Dependencies: Uses only PHP built-in extensions (curl, json)
Usage
Initialize the Client
use Techulus\Capture\Capture; $client = new Capture('your-api-key', 'your-api-secret'); // Use edge endpoint for faster response times $client = new Capture('your-api-key', 'your-api-secret', ['useEdge' => true]);
Building URLs
Image Capture
$imageUrl = $client->buildImageUrl('https://example.com'); $imageUrl = $client->buildImageUrl('https://example.com', [ 'full' => true, 'delay' => 2, 'vw' => 1920, 'vh' => 1080, ]);
PDF Capture
$pdfUrl = $client->buildPdfUrl('https://example.com'); $pdfUrl = $client->buildPdfUrl('https://example.com', [ 'format' => 'A4', 'landscape' => true, ]);
Content Extraction
$contentUrl = $client->buildContentUrl('https://example.com');
Metadata Extraction
$metadataUrl = $client->buildMetadataUrl('https://example.com');
Animated GIF
$animatedUrl = $client->buildAnimatedUrl('https://example.com');
Fetching Data
Fetch Image
$imageData = $client->fetchImage('https://example.com'); file_put_contents('screenshot.png', $imageData);
Fetch PDF
$pdfData = $client->fetchPdf('https://example.com', ['full' => true]); file_put_contents('page.pdf', $pdfData);
Fetch Content
$content = $client->fetchContent('https://example.com'); echo $content['html']; echo $content['textContent']; echo $content['markdown'];
Fetch Metadata
$metadata = $client->fetchMetadata('https://example.com'); print_r($metadata['metadata']);
Fetch Animated GIF
$gifData = $client->fetchAnimated('https://example.com'); file_put_contents('animation.gif', $gifData);
Configuration Options
Constructor Options
useEdge(bool): Use edge.capture.page instead of cdn.capture.page for faster response timestimeout(int): cURL timeout in seconds. Defaults to30
API Endpoints
The SDK supports two base URLs:
- CDN:
https://cdn.capture.page(default) - Edge:
https://edge.capture.page(whenuseEdgeistrue)
License
MIT
Links
Support
For support, please visit capture.page or open an issue on GitHub.