The Screenshot endpoint captures screenshots of web pages with full JavaScript
rendering support.
API Reference: https://spider.cloud/docs/api#screenshot
response = SpiderCloud.screenshot( 'https://example.com' )
# Save to file
response.result.save_to( 'screenshot.png' )
# Or access raw image data
image_data = response.result.image_data
options = SpiderCloud::ScreenshotOptions.build do
full_page true
viewport do
width 1920
height 1080
end
end
response = SpiderCloud.screenshot( 'https://example.com', options )
| Option |
Type |
Default |
Description |
full_page |
Boolean |
true |
Capture full scrollable page |
binary |
Boolean |
false |
Return binary instead of base64 |
omit_background |
Boolean |
false |
Transparent background (PNG only) |
block_images |
Boolean |
false |
Block images for faster capture |
Chrome DevTools Protocol parameters for advanced control:
cdp_params do
format :png # :png or :jpeg
quality 80 # JPEG quality (0-100)
from_surface true
capture_beyond_viewport true
clip do
x 0
y 0
width 800
height 600
scale 1
end
end
| Option |
Type |
Description |
viewport |
Hash |
Browser viewport {width:, height:} |
device |
Symbol |
Device: :mobile, :tablet, :desktop |
wait_for do
# Wait for CSS selector
selector '#loaded'
# Wait for network idle
idle_network do
timeout { seconds 5; nanoseconds 0 }
end
# Wait for delay
delay do
timeout { seconds 2; nanoseconds 0 }
end
end
| Option |
Type |
Description |
stealth |
Boolean |
Stealth mode |
fingerprint |
Boolean |
Use fingerprint detection |
scroll |
Integer |
Scroll duration before capture (ms) |
block_ads |
Boolean |
Block ads |
virtual_display |
Boolean |
Use virtual display |
| Option |
Type |
Description |
proxy |
Symbol |
Proxy pool: :residential, :mobile, :isp |
proxy_enabled |
Boolean |
Enable proxy |
country_code |
String |
ISO country code |
| Option |
Type |
Description |
cookies |
String |
HTTP cookies |
headers |
Hash |
Custom HTTP headers |
automation_scripts |
Hash |
Path-based automation |
response = SpiderCloud.screenshot( 'https://example.com' )
response.result.success? # => true
response.result.content # => "iVBORw0KGgo..." (base64)
response.result.image_data # => binary PNG/JPEG data
response.result.url # => "https://example.com"
response.result.status # => 200
# Save directly to file
response.result.save_to( 'screenshot.png' )
options = SpiderCloud::ScreenshotOptions.build do
full_page true
end
response = SpiderCloud.screenshot( 'https://example.com', options )
response.result.save_to( 'full-page.png' )
options = SpiderCloud::ScreenshotOptions.build do
full_page false
viewport do
width 1280
height 720
end
end
response = SpiderCloud.screenshot( 'https://example.com', options )
options = SpiderCloud::ScreenshotOptions.build do
device :mobile
viewport do
width 375
height 812
end
end
response = SpiderCloud.screenshot( 'https://example.com', options )
options = SpiderCloud::ScreenshotOptions.build do
cdp_params do
format :jpeg
quality 85
end
end
response = SpiderCloud.screenshot( 'https://example.com', options )
response.result.save_to( 'screenshot.jpg' )
options = SpiderCloud::ScreenshotOptions.build do
cdp_params do
clip do
x 100
y 100
width 400
height 300
scale 1
end
end
end
response = SpiderCloud.screenshot( 'https://example.com', options )
options = SpiderCloud::ScreenshotOptions.build do
wait_for do
selector '.chart-loaded'
end
end
response = SpiderCloud.screenshot( 'https://example.com/dashboard', options )
options = SpiderCloud::ScreenshotOptions.build do
proxy :residential
proxy_enabled true
country_code 'UK'
end
response = SpiderCloud.screenshot( 'https://example.com', options )
options = SpiderCloud::ScreenshotOptions.build do
omit_background true
cdp_params do
format :png
end
end
response = SpiderCloud.screenshot( 'https://example.com', options )