# Website Image Scraper (`crawlerbros/website-image-scraper`) Actor

Extract every image URL from a website. Crawls the start page (and optionally internal links up to a configurable depth), parses `<img>` tags, `<picture>`/`<source>`, `srcset` candidates, and CSS `background-image` declarations. HTTP-only, no proxy or browser needed.

- **URL**: https://apify.com/crawlerbros/website-image-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** Automation, Developer tools, Other
- **Stats:** 4 total users, 1 monthly users, 100.0% runs succeeded, 20 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $1.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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Website Image Scraper

Extract every image URL from a website. Crawls the start page (and optionally internal links up to a configurable depth), then parses `<img>` tags, `<picture>`/`<source>`, `srcset` candidates, `<link rel="icon">`, and CSS `background-image` declarations. HTTP-only — no browser, no proxy, no API key.

### What it does

- **Pull every image URL referenced on a page** — `<img src>`, lazy-loaded `data-src`, srcset candidates, picture sources, favicons, inline `style="background-image: url(...)"`.
- **Crawl deeper** — follow internal links up to `maxCrawlDepth` (same host only) to grab images from linked pages too.
- **Filter by format** — restrict to specific extensions (e.g. only SVG, only WebP/AVIF).
- **Bounded** — `maxImagesPerPage` and `maxTotalImages` keep runs cost-predictable on large galleries.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `startUrl` | string (required) | `https://apify.com` | Page to start crawling. Must be `http://` or `https://`. |
| `maxCrawlDepth` | integer | `1` (0–5) | 0 = only the start URL; 1+ = follow internal links one level (same host only). |
| `maxImagesPerPage` | integer | `200` (1–5000) | Cap per page — keeps pathological galleries bounded. |
| `maxTotalImages` | integer | `1000` (1–50000) | Hard cap on total images emitted across the whole run. |
| `imageExtensions` | array | `[jpg, jpeg, png, gif, webp, svg, avif, bmp, ico]` | Only URLs whose path ends in one of these are kept. |
| `includeBackgroundImages` | boolean | `true` | Also extract from inline `style="background-image: url(...)"`. |
| `userAgent` | string | (Chrome 131) | Optional UA override. |

#### Example input

```json
{
  "startUrl": "https://apify.com",
  "maxCrawlDepth": 1,
  "maxImagesPerPage": 200,
  "maxTotalImages": 500,
  "imageExtensions": ["jpg", "png", "webp", "svg"],
  "includeBackgroundImages": true
}
````

### Output

One record per unique image URL. Empty fields are omitted (no nulls).

```json
{
  "url": "https://apify.com/static/hero.jpg",
  "sourcePage": "https://apify.com/",
  "pageTitle": "Apify · The full-stack web-scraping & automation platform",
  "alt": "Apify hero image",
  "hasAltText": true,
  "title": "Apify",
  "width": 1200,
  "height": 600,
  "extension": "jpg",
  "discoveredVia": "img-tag",
  "mimeTypeHint": "image/jpeg",
  "crawlDepth": 0,
  "scrapedAt": "2024-12-16T14:23:11+00:00"
}
```

#### Output fields

- **`url`** — absolute URL of the image (data: URIs and javascript: pseudo-URLs are filtered out).
- **`sourcePage`** — the page where the image was discovered.
- **`pageTitle`** — `<title>` of the page where the image was found (handy for grouping the dataset by page name).
- **`alt`** — `alt` attribute of the `<img>` tag (when present).
- **`hasAltText`** — derived boolean: `true` when `alt` is present and non-empty. Lets you filter accessibility issues without testing for field presence.
- **`title`** — `title` attribute (when present).
- **`width`** / **`height`** — explicit pixel dimensions from the tag (only emitted when numeric).
- **`extension`** — lowercase file extension parsed from the URL path (e.g. `"jpg"`, `"svg"`, `"webp"`). Useful for format-bucket aggregations.
- **`discoveredVia`** — one of `img-tag`, `srcset`, `picture-source`, `link-icon`, `css-background`.
- **`mimeTypeHint`** — derived from the file extension (e.g. `image/png`, `image/svg+xml`).
- **`crawlDepth`** — depth at which the page was crawled (0 = startUrl).
- **`scrapedAt`** — ISO-8601 timestamp.

### Use cases

- **Content audits** — see every image a website serves up, broken down by source (img tag vs CSS background).
- **Asset inventory** — pull all logos, hero images, and icons from a competitor or brand site.
- **Format migration** — find every JPEG/PNG to convert to WebP/AVIF, or every PNG to convert to SVG.
- **SEO / accessibility** — list images with `hasAltText: false` to flag accessibility issues at a glance.

### FAQ

**Does it download the image binaries?**
No. The actor only collects URLs and metadata. Combine with a separate downloader (or pipe URLs into Apify's standard "URL list" actor) if you need the bytes.

**Does it work on JavaScript-rendered pages?**
Mostly no. This scraper is HTTP-only — it sees the server-rendered HTML, not what runs after the page boots. If a site lazy-loads images via React/Vue, you may only see fallback / placeholder images. For SPA-rendered content, use a Playwright-based actor instead.

**Can I limit it to a single page?**
Set `maxCrawlDepth: 0`. Only the start URL is fetched.

**Does it follow external links?**
No. Internal-link crawling only follows links to the same host as `startUrl` to keep cost and scope bounded.

**What if the site has no images at all?**
You get a single sentinel record `{"type": "website_image_scraper_error", "reason": "no_images_found"}` so the dataset is non-empty. The run still completes successfully.

**How does it deduplicate?**
By absolute URL. The same image referenced from multiple pages produces one record (the first-seen page is recorded as `sourcePage`).

# Actor input Schema

## `startUrl` (type: `string`):

The page to start crawling from (e.g. 'https://example.com'). The actor extracts images from this page and, if `maxCrawlDepth >= 1`, follows internal links to additional pages on the same host.

## `maxCrawlDepth` (type: `integer`):

0 = only the start URL. 1 = also follow links found on the start URL (same host only). Higher values widen the crawl but cost more time.

## `maxImagesPerPage` (type: `integer`):

Cap on how many images are extracted from a single page. Pathological gallery pages can list hundreds of duplicates; this keeps runs bounded.

## `maxTotalImages` (type: `integer`):

Hard cap on the total number of image records pushed across all crawled pages. The crawl stops once this many images are emitted.

## `imageExtensions` (type: `array`):

Only image URLs whose path ends in one of these extensions are kept. Drop entries to filter to a subset (e.g. only \['svg']) or extend with custom formats.

## `includeBackgroundImages` (type: `boolean`):

Also extract images referenced via inline `style="background-image: url(...)"` attributes. Disable to only collect `<img>`-sourced images.

## `userAgent` (type: `string`):

Override the default Chrome User-Agent string. Most sites accept the default; only set this if a target server filters by UA.

## Actor input object example

```json
{
  "startUrl": "https://apify.com",
  "maxCrawlDepth": 1,
  "maxImagesPerPage": 200,
  "maxTotalImages": 1000,
  "imageExtensions": [
    "jpg",
    "jpeg",
    "png",
    "gif",
    "webp",
    "svg",
    "avif",
    "bmp",
    "ico"
  ],
  "includeBackgroundImages": 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 = {
    "startUrl": "https://apify.com",
    "maxCrawlDepth": 1,
    "maxImagesPerPage": 200,
    "maxTotalImages": 1000,
    "imageExtensions": [
        "jpg",
        "jpeg",
        "png",
        "gif",
        "webp",
        "svg",
        "avif",
        "bmp",
        "ico"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/website-image-scraper").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 = {
    "startUrl": "https://apify.com",
    "maxCrawlDepth": 1,
    "maxImagesPerPage": 200,
    "maxTotalImages": 1000,
    "imageExtensions": [
        "jpg",
        "jpeg",
        "png",
        "gif",
        "webp",
        "svg",
        "avif",
        "bmp",
        "ico",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/website-image-scraper").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 '{
  "startUrl": "https://apify.com",
  "maxCrawlDepth": 1,
  "maxImagesPerPage": 200,
  "maxTotalImages": 1000,
  "imageExtensions": [
    "jpg",
    "jpeg",
    "png",
    "gif",
    "webp",
    "svg",
    "avif",
    "bmp",
    "ico"
  ]
}' |
apify call crawlerbros/website-image-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Website Image Scraper",
        "description": "Extract every image URL from a website. Crawls the start page (and optionally internal links up to a configurable depth), parses `<img>` tags, `<picture>`/`<source>`, `srcset` candidates, and CSS `background-image` declarations. HTTP-only, no proxy or browser needed.",
        "version": "0.1",
        "x-build-id": "5lafNCefriCSMGxiM"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/crawlerbros~website-image-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-crawlerbros-website-image-scraper",
                "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/crawlerbros~website-image-scraper/runs": {
            "post": {
                "operationId": "runs-sync-crawlerbros-website-image-scraper",
                "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/crawlerbros~website-image-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-crawlerbros-website-image-scraper",
                "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": [
                    "startUrl"
                ],
                "properties": {
                    "startUrl": {
                        "title": "Start URL",
                        "type": "string",
                        "description": "The page to start crawling from (e.g. 'https://example.com'). The actor extracts images from this page and, if `maxCrawlDepth >= 1`, follows internal links to additional pages on the same host."
                    },
                    "maxCrawlDepth": {
                        "title": "Maximum crawl depth",
                        "minimum": 0,
                        "maximum": 5,
                        "type": "integer",
                        "description": "0 = only the start URL. 1 = also follow links found on the start URL (same host only). Higher values widen the crawl but cost more time.",
                        "default": 1
                    },
                    "maxImagesPerPage": {
                        "title": "Maximum images per page",
                        "minimum": 1,
                        "maximum": 5000,
                        "type": "integer",
                        "description": "Cap on how many images are extracted from a single page. Pathological gallery pages can list hundreds of duplicates; this keeps runs bounded.",
                        "default": 200
                    },
                    "maxTotalImages": {
                        "title": "Maximum images per run",
                        "minimum": 1,
                        "maximum": 50000,
                        "type": "integer",
                        "description": "Hard cap on the total number of image records pushed across all crawled pages. The crawl stops once this many images are emitted.",
                        "default": 1000
                    },
                    "imageExtensions": {
                        "title": "Image extensions to accept",
                        "type": "array",
                        "description": "Only image URLs whose path ends in one of these extensions are kept. Drop entries to filter to a subset (e.g. only ['svg']) or extend with custom formats.",
                        "default": [
                            "jpg",
                            "jpeg",
                            "png",
                            "gif",
                            "webp",
                            "svg",
                            "avif",
                            "bmp",
                            "ico"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "includeBackgroundImages": {
                        "title": "Include CSS background-images",
                        "type": "boolean",
                        "description": "Also extract images referenced via inline `style=\"background-image: url(...)\"` attributes. Disable to only collect `<img>`-sourced images.",
                        "default": true
                    },
                    "userAgent": {
                        "title": "Custom User-Agent (optional)",
                        "type": "string",
                        "description": "Override the default Chrome User-Agent string. Most sites accept the default; only set this if a target server filters by UA."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
