Site-Shot - Capture A Website Screenshot

Documentation

This documentation describe all available parameters and at least one example for each parameter

API call sample

https://api.site-shot.com/?url=www.com&userkey=HQKRAKBKRARAAJBKYEIAAQ

Url

Specify API key and a web-site URL to create screenshot, remember that all parameters needs to be url encoded.

&url=https://www.wikipedia.org/

Width

Set webview width in pixels, default value: 1024px

Values range: 100 - 8000

&width=1280

Height

Set webview height in pixels, default value: 768px

Values range: 100 - 20000

&height=1024

Zoom

Set webview percentage zoom, default value: 100

Values range: 5 - 1000

&zoom=200

Full size

Capture entire document canvas, default value: 0

Document maximum height is limited by max_height parameter

&full_size=1

Max height

Set webview maximum height in pixels, default value: 15000px

The max-height parameter is only relevant if full_size is set to 1

Values range: 100 - 20000

&max_height=5000&height=1280&full_size=1

User agent

Specify a custom user agent string

The value have to be url encoded, provided example below contains user agent string for browser Chromium

&user_agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/64.0.3282.167 Chrome/64.0.3282.167 Safari/537.36

Scaled width

Scale result image to specified width

The value can not be smaller than height

Values range: 50 - 10000

&scaled_width=200

Format

Image format, default value: PNG

Possible values: PNG, JPEG

&format=jpeg

Response type

API response content-type, default value: image

In case of JSON response, API provide image encoded in base64 and extra information: http response code, http response headers, error in case of unsuccessful response

Possible values: IMAGE, JSON

&response_type=image

API key

Your personal unique identifier.

You can get it after signup process in Dashboard

Please keep the key in secret

&userkey=HQKRAKBKHII6RARAAJBKYEIAAQ

Delay time

Delay the screenshot capture, default value: 1500.

Have to be specified in milliseconds

Values range: 0 - 60000

&delay_time=2000

Timeout

Limit the maximum time for screenshot creation, default value: 60000

If screenshot isn't created in time API return timeout error

Have to be specified in milliseconds

Values range: 0 - 120000

&timeout=60000

Request headers

Specify a custom request headers fields

Allowed multiple request_header parameters

Provided examples below, specified Cookie and Referer http headers

&request_header=Cookie:SSID=WX84BVOEA3WEDSHJHG &request_header=Referer:http://www.website.com/

Http proxy

Specify a http proxy server, default value: http://localhost:3128

&http_proxy=http://localhost:3128

Proxy username

Specify an username for proxy server

&proxy_username=james

Proxy password

Specify a password for proxy server

&proxy_password=changeme

Source code

Get the rendered source code of the web page, default value: 0

Applicable only together with response_type=json

&source_code=1

Javscript code

Ingest custom JavaScript code into the web page

&javascript_code=document.getElementById('uc-central-banner-modal').style="display:none"

Proxy rotation

High quality proxy would be automatically rotated, default value: 1

&proxy_rotation=1

No cookie popup

Block cookie banners on websites, default value: 0

&no_cookie_popup=1

No ads

Block ads from popular ad-networks, default value: 0

&no_ads=1

Country

Specifies the geographic country for the screenshot request

Automatically sets a proxy IP from the selected country

Also automatically sets default language, time zone and geolocation coordinates for that country if they are not manually overridden

A list of available countries and their default settings can be found the countries reference page.

&country=Br

Geolocation

Simulates precise physical browser location using latitude and longitude coordinates

Has no effect on IP-based geolocation (use country for that)

Can be combined with country to simulate both network and GPS presence

Format: A comma-separated string of latitude and longitude

&geolocation=48.8566,2.3522

(Simulates the browser being located in Paris, France)

Language

Sets the default browser language (e.g., for the Accept-Language header)

If country is provided and language is not, the language is taken from the country setting

If language is explicitly provided, it overwrites any default set by country

&language=ja

Time zone

Sets the time zone to be used by the browser

If country is provided and time_zone is not, the time zone is taken from the country setting

If time_zone is explicitly provided, it overwrites any default set by country

Default Value: America/New_York (if no country is specified)

A list of available time zones can be found the time zones reference page.

&time_zone=Europe/London

Combined Example

Below is a combined example demonstrating the country, geolocation, language, and time_zone parameters together:

https://api.site-shot.com/?url=https%3A%2F%2Fwww.wikipedia.org%2F&userkey=YOUR_API_KEY&country=Brazil&geolocation=35.6895,139.6917&language=ja&time_zone=Asia/Tokyo&width=1280&height=1024

Explanation: country=Brazil - Sets a Brazilian proxy IP and defaults (unless overridden). geolocation=35.6895,139.6917 - Simulates the browser being physically located in Tokyo, Japan. language=ja - Overrides the default Portuguese with Japanese. time_zone=Asia/Tokyo - Overrides the default Brazilian time zone.

Code Samples

Just copy code for your language and add API key.

Python PHP Bash Perl #!/usr/bin/python3 import base64 import requests def get_screenshot(params): headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain", "userkey": "HQKRAKBKRARAAJBKYEIAAQ"} try: r = requests.post('https://api.site-shot.com/', headers=headers, data=params) if (r.status_code == requests.codes.ok): return r.json() elif (r.status_code == 404): print("Screenshot hasn't been generated. The error: " + r.json().error) elif (r.status_code == 401): print("Invalid authentication token") elif (r.status_code == 403): print("Active subscription hasn't been found") except requests.exceptions.RequestException as e: print('Screenshot generation has failed, the error: ' + str(e)) def main(): screenshot = get_screenshot( {'url': 'https://site-shot.com/', 'width': 1280, 'height': 1280, 'format': 'png', 'response_type': 'json', 'delay_time': 2000, 'timeout': 60000}) if screenshot is not None: base64_image = screenshot['image'].split(',', maxsplit=1)[1] image_file = open('screenshot.png', 'wb') image_file.write(base64.b64decode(base64_image)) image_file.close() main() <?php // your access key, can be found here https://www.site-shot.com/dashboard/ define('ACCESS_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXX'); // api endpoint define('API_URI', 'https://api.site-shot.com'); // folder for the cached screenshots define('CACHE_DIR', '/tmp'); // how much time screenshot will be cached, defined in seconds define('CACHE_EXPIRATION', 60*60*24*1); // Screenshot parameters // screenshot witdh define('SCR_WIDTH', 1024); // screenshot heigth, or minimum height in case if full size option enabled define('SCR_HEIGHT', 1920); // delay time in miliseconds, to make sure all the content is loadded define('SCR_DELAY_TIME', 3000); // timeout in miliseconds 0-120000, maximum time allocated for the screenshot creation // in case if timeout too small timeout error would be recieved define('SCR_TIMEOUT', 90000); function downloadScreenshot($url) { $query_string = http_build_query(array( 'url' => $url, 'userkey' => ACCESS_KEY, 'width' => SCR_WIDTH, 'height' => SCR_HEIGHT, 'delay_time' => SCR_DELAY_TIME, 'timeout' => SCR_TIMEOUT, 'response_type' => 'json', )); $image = file_get_contents(API_URI."/?$query_string"); return $image; } function getScreenshot($url) { $file_name = CACHE_DIR . '/' . md5($url); $screenshot_json = False; if (CACHE_EXPIRATION > 0 and file_exists($file_name)) { if (filemtime($file_name) + CACHE_EXPIRATION > time()) { $screenshot_json = file_get_contents($file_name); } } if (! $screenshot_json) { $screenshot_json = downloadScreenshot($url); if (CACHE_EXPIRATION > 0) { file_put_contents($file_name, $screenshot_json); } } return $screenshot_json; } function run() { $url = 'https://youtube.com'; $screenshot_json = json_decode(getScreenshot($url)); $data = explode(',', $screenshot_json->image); $image = base64_decode($data[1]); header("Content-Type: image/png"); echo($image); } run(); ?>
to be added
to be added

High Availability

We provide highly available service, with 99.9% uptime!

Easy to Start

You can try out our service for free, no need to register.

Horizontal Scalability

We can increase capacity as much as you need!

Fast API

Fast screenshot rendering, no need to wait.

Let's Get In Touch!

[email protected]

Company name: WEB SCRAPER LLP

Tag » How Do I Shot Web