Customize Taking a Website Screenshots via ScraperAPI in Ruby
Learn how to take a screenshot of a page when scraping with ScraperAPI in Ruby. Capture page images using screenshot=true. Ideal for monitoring and documentation.
Our Java Script solution now gives you the ability to take a screenshot of the target page through the use of the parameter screenshot=true
. This parameter automatically enables JS rendering to get the full page content, before taking a screenshot.
After we serve the response, you can find the screenshot URL in the sa-screenshot
response header. The screenshot format is PNG
:

API REQUEST
require 'net/http'
require 'json'
params = {
:api_key => "API_KEY",
:screenshot => "true",
:url => "https://example.com/"
}
uri = URI('https://api.scraperapi.com/')
uri.query = URI.encode_www_form(params)
response = Net::HTTP.get_response(uri)
puts "Response Headers:"
response.each_header { |key, value| puts "#{key}: #{value}" }
puts "\nResponse Body:"
puts response.body
ASYNC REQUEST
require 'net/http'
require 'json'
uri = URI('https://async.scraperapi.com/jobs')
payload = {
"apiKey" => "API_KEY",
"url" => "https://example.com",
"apiParams" => {
"screenshot" => true
}
}
json_payload = payload.to_json
response = Net::HTTP.post(uri, json_payload, "Content-Type" => "application/json")
print(response.body)
PROXY MODE - COMING SOON!
PreviousUse Render Instruction Set to Scrape Dynamic Pages in RubyNextCustomize Scrape Session-Based Proxies via ScraperAPI in Ruby
Last updated
Was this helpful?