Skip to content

techulus/capture-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Capture Ruby SDK

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

Installation

Add to your Gemfile:

gem "capture_page"

Or install directly:

gem install capture_page

Quick Start

require "capture"

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

image_url = client.build_image_url("https://example.com")
puts 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
  • Zero Dependencies: Uses only Ruby standard library

Usage

Initialize the Client

require "capture"

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

# Use edge endpoint for faster response times
client = Capture.new("your-api-key", "your-api-secret", use_edge: true)

Building URLs

Image Capture

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

image_url = client.build_image_url("https://example.com", {
  "full" => true,
  "delay" => 2,
  "vw" => 1920,
  "vh" => 1080
})

PDF Capture

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

pdf_url = client.build_pdf_url("https://example.com", {
  "format" => "A4",
  "landscape" => true
})

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

Fetch Image

image_data = client.fetch_image("https://example.com")
File.binwrite("screenshot.png", image_data)

Fetch PDF

pdf_data = client.fetch_pdf("https://example.com", { "full" => true })
File.binwrite("page.pdf", pdf_data)

Fetch Content

content = client.fetch_content("https://example.com")
puts content["html"]
puts content["textContent"]
puts content["markdown"]

Fetch Metadata

metadata = client.fetch_metadata("https://example.com")
puts metadata["metadata"]

Fetch Animated GIF

gif_data = client.fetch_animated("https://example.com")
File.binwrite("animation.gif", gif_data)

Configuration Options

Constructor Options

  • use_edge (boolean): 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 use_edge: true)

License

MIT

Links

Support

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

About

Official Ruby SDK for Capture

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages