# Screenshot Saver (`codingfrontend/screenshot-saver`) Actor

Capture screenshots of websites and save to cloud storage. Supports multiple URLs, full page capture, custom viewports, and various output destinations.

- **URL**: https://apify.com/codingfrontend/screenshot-saver.md
- **Developed by:** [codingfrontend](https://apify.com/codingfrontend) (community)
- **Categories:** Automation, Developer tools, Other
- **Stats:** 12 total users, 0 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Screenshot Saver - Apify Actor

A simple screenshot capture Actor that takes screenshots of websites with built-in bot detection bypass and stealth mode.

### Features

- **Multiple formats**: PNG (lossless), JPEG (smaller files), PDF (documents)
- **Full page screenshots**: Capture entire scrollable pages
- **Stealth mode**: Built-in anti-detection measures
- **Auto-retry**: Handles blocked requests gracefully
- **CSS selector hiding**: Hide cookies banners, popups, ads

### Usage

#### Basic Example
```json
{
    "urls": [{ "url": "https://example.com" }]
}
````

#### Mobile Screenshot

```json
{
    "urls": [{ "url": "https://example.com" }],
    "windowWidth": 375,
    "windowHeight": 812
}
```

#### Hide Elements

```json
{
    "urls": [{ "url": "https://example.com" }],
    "selectorsToHide": ".cookie-banner, .popup"
}
```

### Input Parameters

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `urls` | array | required | URLs to screenshot |
| `format` | string | "png" | Output format: png, jpeg, pdf |
| `fullPage` | boolean | true | Capture full scrollable page |
| `windowWidth` | integer | 1920 | Browser window width |
| `windowHeight` | integer | 1080 | Browser window height |
| `selectorsToHide` | string | "" | CSS selectors to hide |
| `proxy` | object | Apify Proxy | Proxy configuration |

### Output

Screenshots are saved to Apify Key-Value Store with public URLs.

```json
{
    "timestamp": "2024-01-15T10:30:00.000Z",
    "startUrl": "https://example.com",
    "url": "https://example.com/",
    "screenshotUrl": "https://api.apify.com/v2/key-value-stores/.../records/screenshot_...",
    "screenshotKey": "screenshot_https___example_com_a1b2c3d4",
    "format": "png"
}
```

### Development

```bash
npm install
npm start
npm run lint
```

# Actor input Schema

## `urls` (type: `array`):

List of URLs to capture screenshots of.

## `format` (type: `string`):

Screenshot format. PNG is lossless, JPEG is smaller, PDF renders the whole page as a document.

## `fullPage` (type: `boolean`):

Capture the entire scrollable page height, not just the visible viewport.

## `windowWidth` (type: `integer`):

Browser window width in pixels. Use 375 for mobile, 768 for tablet, 1920 for desktop.

## `windowHeight` (type: `integer`):

Browser window height in pixels.

## `quality` (type: `integer`):

JPEG compression quality (1–100). Lower = smaller file size. Only applies when format is 'jpeg'.

## `waitUntil` (type: `string`):

When to consider the page fully loaded before taking the screenshot.

## `waitForSelector` (type: `string`):

CSS selector to wait for before taking the screenshot. Useful for dynamic pages. Example: '#main-content' or '.product-list'

## `waitForTimeout` (type: `integer`):

Additional time to wait (in milliseconds) after the page loads before taking the screenshot. Useful for animations or lazy-loading content.

## `scrollToBottom` (type: `boolean`):

Slowly scroll to the bottom of the page before taking the screenshot, triggering lazy-loaded images and content.

## `clickSelector` (type: `string`):

CSS selector of an element to click before taking the screenshot. Useful for closing cookie banners, opening menus, or dismissing popups. Example: '.cookie-accept', '#close-popup'

## `selectorsToHide` (type: `string`):

Comma-separated CSS selectors of elements to hide before taking the screenshot. Example: '.cookie-banner, .ads, .newsletter-popup'

## `injectCss` (type: `string`):

Custom CSS to inject into the page before taking the screenshot. Example: 'body { background: white; } .banner { display: none; }'

## `injectJs` (type: `string`):

Custom JavaScript to execute on the page before taking the screenshot. Example: 'document.querySelector(".sidebar").remove();'

## `captureSelector` (type: `string`):

CSS selector of a specific element to screenshot instead of the whole page. Example: '#product-card' or '.data-table'. Overrides fullPage setting.

## `mobileEmulation` (type: `string`):

Emulate a specific mobile device. Overrides windowWidth/windowHeight settings.

## `deviceScaleFactor` (type: `number`):

Device pixel ratio for retina/HiDPI screenshots. Use 1 for standard, 2 for retina quality.

## `blockResources` (type: `array`):

Block specific resource types to speed up page loading. Useful for getting a text-only or CSS-only view.

## `username` (type: `string`):

Username for HTTP Basic Authentication (for password-protected pages).

## `password` (type: `string`):

Password for HTTP Basic Authentication.

## `cookies` (type: `array`):

Array of cookies to set before navigating. Use to bypass cookie consent or inject session tokens. Example: \[{"name": "session", "value": "abc123", "domain": ".example.com"}]

## `headers` (type: `object`):

Additional HTTP headers to send with every request. Example: {"Authorization": "Bearer token123", "X-Custom": "value"}

## `proxy` (type: `object`):

Proxy settings. Use Apify Proxy for better success rates on protected sites.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://example.com"
    }
  ],
  "format": "png",
  "fullPage": true,
  "windowWidth": 1920,
  "windowHeight": 1080,
  "quality": 80,
  "waitUntil": "networkidle2",
  "waitForTimeout": 0,
  "scrollToBottom": true,
  "mobileEmulation": "",
  "deviceScaleFactor": 1,
  "blockResources": [],
  "proxy": {
    "useApifyProxy": true
  }
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        {
            "url": "https://example.com"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("codingfrontend/screenshot-saver").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": [{ "url": "https://example.com" }] }

# Run the Actor and wait for it to finish
run = client.actor("codingfrontend/screenshot-saver").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    {
      "url": "https://example.com"
    }
  ]
}' |
apify call codingfrontend/screenshot-saver --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=codingfrontend/screenshot-saver",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Screenshot Saver",
        "description": "Capture screenshots of websites and save to cloud storage. Supports multiple URLs, full page capture, custom viewports, and various output destinations.",
        "version": "1.0",
        "x-build-id": "vzpsOZRpWyi4oRLr0"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/codingfrontend~screenshot-saver/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-codingfrontend-screenshot-saver",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/codingfrontend~screenshot-saver/runs": {
            "post": {
                "operationId": "runs-sync-codingfrontend-screenshot-saver",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/codingfrontend~screenshot-saver/run-sync": {
            "post": {
                "operationId": "run-sync-codingfrontend-screenshot-saver",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "urls"
                ],
                "properties": {
                    "urls": {
                        "title": "URLs",
                        "type": "array",
                        "description": "List of URLs to capture screenshots of.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "format": {
                        "title": "Output Format",
                        "enum": [
                            "png",
                            "jpeg",
                            "pdf"
                        ],
                        "type": "string",
                        "description": "Screenshot format. PNG is lossless, JPEG is smaller, PDF renders the whole page as a document.",
                        "default": "png"
                    },
                    "fullPage": {
                        "title": "Full Page Screenshot",
                        "type": "boolean",
                        "description": "Capture the entire scrollable page height, not just the visible viewport.",
                        "default": true
                    },
                    "windowWidth": {
                        "title": "Viewport Width (px)",
                        "minimum": 100,
                        "maximum": 3840,
                        "type": "integer",
                        "description": "Browser window width in pixels. Use 375 for mobile, 768 for tablet, 1920 for desktop.",
                        "default": 1920
                    },
                    "windowHeight": {
                        "title": "Viewport Height (px)",
                        "minimum": 100,
                        "maximum": 2160,
                        "type": "integer",
                        "description": "Browser window height in pixels.",
                        "default": 1080
                    },
                    "quality": {
                        "title": "JPEG Quality",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "JPEG compression quality (1–100). Lower = smaller file size. Only applies when format is 'jpeg'.",
                        "default": 80
                    },
                    "waitUntil": {
                        "title": "Wait Until",
                        "enum": [
                            "domcontentloaded",
                            "load",
                            "networkidle0",
                            "networkidle2"
                        ],
                        "type": "string",
                        "description": "When to consider the page fully loaded before taking the screenshot.",
                        "default": "networkidle2"
                    },
                    "waitForSelector": {
                        "title": "Wait For Selector",
                        "type": "string",
                        "description": "CSS selector to wait for before taking the screenshot. Useful for dynamic pages. Example: '#main-content' or '.product-list'"
                    },
                    "waitForTimeout": {
                        "title": "Extra Wait Time (ms)",
                        "minimum": 0,
                        "maximum": 30000,
                        "type": "integer",
                        "description": "Additional time to wait (in milliseconds) after the page loads before taking the screenshot. Useful for animations or lazy-loading content.",
                        "default": 0
                    },
                    "scrollToBottom": {
                        "title": "Scroll To Bottom Before Screenshot",
                        "type": "boolean",
                        "description": "Slowly scroll to the bottom of the page before taking the screenshot, triggering lazy-loaded images and content.",
                        "default": true
                    },
                    "clickSelector": {
                        "title": "Click Element Before Screenshot",
                        "type": "string",
                        "description": "CSS selector of an element to click before taking the screenshot. Useful for closing cookie banners, opening menus, or dismissing popups. Example: '.cookie-accept', '#close-popup'"
                    },
                    "selectorsToHide": {
                        "title": "Hide Elements (CSS selectors)",
                        "type": "string",
                        "description": "Comma-separated CSS selectors of elements to hide before taking the screenshot. Example: '.cookie-banner, .ads, .newsletter-popup'"
                    },
                    "injectCss": {
                        "title": "Inject Custom CSS",
                        "type": "string",
                        "description": "Custom CSS to inject into the page before taking the screenshot. Example: 'body { background: white; } .banner { display: none; }'"
                    },
                    "injectJs": {
                        "title": "Inject Custom JavaScript",
                        "type": "string",
                        "description": "Custom JavaScript to execute on the page before taking the screenshot. Example: 'document.querySelector(\".sidebar\").remove();'"
                    },
                    "captureSelector": {
                        "title": "Capture Specific Element",
                        "type": "string",
                        "description": "CSS selector of a specific element to screenshot instead of the whole page. Example: '#product-card' or '.data-table'. Overrides fullPage setting."
                    },
                    "mobileEmulation": {
                        "title": "Mobile Device Emulation",
                        "enum": [
                            "",
                            "iPhone 15 Pro",
                            "iPhone SE",
                            "Pixel 7",
                            "iPad Pro",
                            "Galaxy S23",
                            "Samsung Galaxy Tab S8"
                        ],
                        "type": "string",
                        "description": "Emulate a specific mobile device. Overrides windowWidth/windowHeight settings.",
                        "default": ""
                    },
                    "deviceScaleFactor": {
                        "title": "Device Scale Factor (DPR)",
                        "minimum": 1,
                        "maximum": 4,
                        "type": "number",
                        "description": "Device pixel ratio for retina/HiDPI screenshots. Use 1 for standard, 2 for retina quality.",
                        "default": 1
                    },
                    "blockResources": {
                        "title": "Block Resource Types",
                        "type": "array",
                        "description": "Block specific resource types to speed up page loading. Useful for getting a text-only or CSS-only view.",
                        "items": {
                            "type": "string"
                        },
                        "default": []
                    },
                    "username": {
                        "title": "HTTP Basic Auth — Username",
                        "type": "string",
                        "description": "Username for HTTP Basic Authentication (for password-protected pages)."
                    },
                    "password": {
                        "title": "HTTP Basic Auth — Password",
                        "type": "string",
                        "description": "Password for HTTP Basic Authentication."
                    },
                    "cookies": {
                        "title": "Custom Cookies",
                        "type": "array",
                        "description": "Array of cookies to set before navigating. Use to bypass cookie consent or inject session tokens. Example: [{\"name\": \"session\", \"value\": \"abc123\", \"domain\": \".example.com\"}]",
                        "items": {
                            "type": "object"
                        }
                    },
                    "headers": {
                        "title": "Custom HTTP Headers",
                        "type": "object",
                        "description": "Additional HTTP headers to send with every request. Example: {\"Authorization\": \"Bearer token123\", \"X-Custom\": \"value\"}"
                    },
                    "proxy": {
                        "title": "Proxy Configuration",
                        "type": "object",
                        "description": "Proxy settings. Use Apify Proxy for better success rates on protected sites.",
                        "default": {
                            "useApifyProxy": true
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
