# Screenshot Taker (`jancurn/screenshot-taker`) Actor

Takes a screenshot of one or more web pages using the Chrome browser. The actor enables the setting of custom viewport size, page load timeout, delay, proxies, and output image format.

- **URL**: https://apify.com/jancurn/screenshot-taker.md
- **Developed by:** [Jan Čurn](https://apify.com/jancurn) (community)
- **Categories:** Developer tools, Open source
- **Features:** Full permissions
- **Stats:** 826 total users, 2 monthly users, 100.0% runs succeeded, 21 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Screenshot taker

This Apify actor takes a screenshot of one or more
web pages using Chrome browser.
The actor enables the setting of custom viewport size,
page load timeout, delay, proxies, and output image format.

### Results

The screenshots are stored in the the default key-value store
associated with the actor run. For each web page on input,
the dataset contains a record such as:

```
{
  "request": {
    "url": "https://www.example.com",
    "method": "GET",
    "payload": null,
    "userData": {}
  },
  "response": {
    "status": 200,
    "headers": {
      "status": "200",
      "content-encoding": "gzip",
      "cache-control": "max-age=604800",
      "content-type": "text/html; charset=UTF-8",
      "content-length": "606"
    }
  },
  "finishedAt": "2019-07-14T16:16:56.230Z",
  "screenshotUrl": "https://api.apify.com/v2/key-value-stores/x2xiRLsycdTpFQFSo/records/screenshot-2c730012.jpeg"
}
```

If an error occurs during loading or processing of a web page,
the page is retried (up to `pageMaxRetryCount` times - see input schema).
If the error persists,
the resulting dataset will contain a record such as the following:

```
{
  "request": {
    "url": "https://non-existing-page.net",
    "method": "GET",
    "payload": null,
    "userData": {}
  },
  "response": null,
  "finishedAt": "2019-07-14T16:24:41.257Z",
  "errorMessages": [
    "Error: net::ERR_NAME_NOT_RESOLVED at https://non-existing-page.net\n    at navigate ...",
    "Error: net::ERR_NAME_NOT_RESOLVED at https://non-existing-page.net\n    at navigate ...",
    "Error: net::ERR_NAME_NOT_RESOLVED at https://non-existing-page.net\n    at navigate ..."
  ]
}
```

# Actor input Schema

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

List of URLs of web pages to take the screenshot of.

## `pageLoadTimeoutSecs` (type: `integer`):

Timeout for the web page load, in seconds. If the web page does not load in this time frame, it is considered to have failed and will be retried, similarly as with other page load errors.

## `pageMaxRetryCount` (type: `integer`):

How many times to retry to load the page on error or timeout.

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

Indicates when to consider the navigation to the page as succeeded. For more details, see <code>waitUntil</code> parameter of <a href='https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options' target='_blank' rel='noopener'>Page.goto()</a> function in Puppeteer documention.

## `viewportWidth` (type: `integer`):

Width of the browser window.

## `viewportHeight` (type: `integer`):

Height of the browser window.

## `delaySecs` (type: `integer`):

How long time to wait after loading the page before taking the screenshot.

## `imageType` (type: `string`):

Format of the image.

## `proxyConfiguration` (type: `object`):

Specifies the type of proxy servers that will be used by the crawler in order to hide its origin.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://www.example.com"
    },
    {
      "url": "https://sdk.apify.com"
    }
  ],
  "pageLoadTimeoutSecs": 60,
  "pageMaxRetryCount": 2,
  "waitUntil": "load",
  "viewportWidth": 1200,
  "viewportHeight": 900,
  "delaySecs": 0,
  "imageType": "jpeg"
}
```

# 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://www.example.com"
        },
        {
            "url": "https://sdk.apify.com"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("jancurn/screenshot-taker").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://www.example.com" },
        { "url": "https://sdk.apify.com" },
    ] }

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

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).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://www.example.com"
    },
    {
      "url": "https://sdk.apify.com"
    }
  ]
}' |
apify call jancurn/screenshot-taker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jancurn/screenshot-taker"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/xDM69LgSdy3tscbqS/builds/BgjjMwMZtxEya2e1W/openapi.json
