Site-Shot - Capture A Website Screenshot

Code Samples

Just copy code for your language and add API key.

Python Node.js PHP Java C# Go Ruby cURL Perl #!/usr/bin/env python3 # pip install requests import base64 import requests API_URL = "https://api.site-shot.com/" API_KEY = "YOUR_API_KEY" def fetch_screenshot(url: str, out_path: str = "screenshot.png") -> None: # API timeout is in milliseconds; requests' timeout is in seconds. params = { "url": url, "userkey": API_KEY, "width": 1280, "height": 1024, "format": "png", "response_type": "json", "delay_time": 2000, "timeout": 60000, } r = requests.get(API_URL, params=params, timeout=70) r.raise_for_status() payload = r.json() if payload.get("error"): raise RuntimeError(payload["error"]) image_field = payload.get("image", "") if not image_field: raise RuntimeError("No image in response") # Some responses include a data URL prefix: data:image/png;base64,... image_b64 = image_field.split(",", 1)[1] if "," in image_field else image_field with open(out_path, "wb") as f: f.write(base64.b64decode(image_b64)) if __name__ == "__main__": fetch_screenshot("https://example.com/")

Tag » How Do I Shot Web