Screenshot Capture🆕

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

<?php
$url =
"https://api.scraperapi.com?api_key=API_KEY&screenshot=true&url=https://example.com"; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
$response = curl_exec($ch); 
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); 
$headers = substr($response, 0, $header_size); 
$body = substr($response, $header_size); 

curl_close($ch); 

echo "Response Headers:\n";
print_r($headers);
echo "\nResponse Body:\n";
print_r($body);
?>
  • ASYNC REQUEST

<?php
$payload = json_encode(
    array(
        "apiKey" => "API_KEY",
        "url" => "https://example.com",
        "apiParams" => array(
            "screenshot" => "true"
        )
    )
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://async.scraperapi.com/jobs");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

$response = curl_exec($ch);
curl_close($ch);
print_r($response);
?>
  • PROXY MODE - COMING SOON!

Last updated

Was this helpful?