# Broken Link Checker: Dead Links, Missing Images, Bad Redirects (`evenwork/broken-link-checker`) Actor

Crawl a website and check every link, image, script and stylesheet. Each broken link comes back with the page it sits on, its link text and the HTTP status. Errors from sites that block checkers, such as Facebook, are marked blocked for a hand check.

- **URL**: https://apify.com/evenwork/broken-link-checker.md
- **Developed by:** [Evenwork](https://apify.com/evenwork) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 page scanneds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

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

## Broken Link Checker: Dead Links, Missing Images, Bad Redirects

Give it a website. It scans the pages, checks every link, image, script, stylesheet and iframe it finds, and returns one row for each problem: the broken link, the page it sits on, the link text and the HTTP status.

Run it after a site migration, or before you send a client the list of dead links on their site.

### What it checks

- Links (`<a>` and image-map `<area>`), images, scripts, stylesheets, iframes, video and audio sources, favicons and canonical tags.
- Links to pages on the same site and links to other websites. www and non-www count as the same site; a subdomain such as blog.example.com counts as another site, so its links are checked but its pages aren't scanned.
- Redirects are followed (up to 10), and the final answer decides the verdict. A redirect loop counts as broken.

Each unique link is checked once per run, however many pages it appears on. The check is a HEAD request. When a server answers HEAD with anything other than 2xx (many answer 405 or 403), the link is requested again with GET, and the GET answer counts.

### Verdicts

| Verdict | Meaning |
|---|---|
| `broken` | 404, 410, any other 4xx, 5xx, a redirect loop, a domain that doesn't resolve, a refused connection or a TLS certificate error |
| `blocked` | The site refused to answer an automated check: 401, 403, 407, 429, 451 or 999. Facebook, Instagram, X, LinkedIn, TikTok, Etsy, Amazon and other large sites often send errors to every checker, so any error from those is `blocked` rather than `broken` (a 404 from them still counts as broken). Check these by hand. |
| `timeout` | No answer within the timeout. Check by hand. |
| `ok` | 2xx. Only output when "Output working links too" is on. |
| `skipped` | Not checked: robots.txt disallows it, it is an IP address or on a private network, or the link check cap was reached. Only output when "Output working links too" is on. |

### Input

```json
{
  "startUrls": ["example.com", "https://www.example.co.uk/blog/"],
  "maxPagesPerSite": 100,
  "maxDepth": 5,
  "onlyUnderStartPath": false,
  "checkExternalLinks": true,
  "checkResources": true,
  "reportBlocked": true,
  "includeOkLinks": false,
  "respectRobotsTxt": true
}
```

Only `startUrls` is required. A bare domain starts at its https:// homepage. If the start page redirects to another domain (example.co.uk to example.com), the checker scans the domain it lands on.

- `maxPagesPerSite`: pages scanned per site, 1 to 10,000 (default 100). Each scanned page is one charged event.
- `maxDepth`: clicks from the start page, 0 to 20 (default 5). 0 scans the start page only.
- `onlyUnderStartPath`: start at example.com/blog/ and only /blog/ pages are scanned. Links to the rest of the site are still checked.
- `checkExternalLinks`, `checkResources`: turn off to skip links to other websites, or images, scripts and stylesheets.
- `reportBlocked`: turn off to hide `blocked` rows.
- `includeOkLinks`: output every link found, one row per page it appears on.
- `respectRobotsTxt`: on by default. Turn off to check pages your own robots.txt hides.
- `maxLinkChecksPerSite`: a safety cap on unique links checked per site (default 5,000).
- `concurrency` (default 10, never more than 5 at once to the site being scanned), `timeoutSecs` (default 15), `userAgent`.

### Output

One row per problem link per page. This row is from a test run against a page we set up with a missing link:

```json
{
  "site": "evenwork.co.uk",
  "sourcePage": "https://evenwork.co.uk/rook/blc-7e41c09a2f/",
  "linkUrl": "https://evenwork.co.uk/rook/blc-7e41c09a2f/missing-page.html",
  "finalUrl": null,
  "element": "a",
  "kind": "link",
  "anchorText": "A page that does not exist",
  "linkType": "internal",
  "status": 404,
  "verdict": "broken",
  "reason": "HTTP 404: page not found"
}
```

- `sourcePage`: the page the link was found on. For a start URL that fails, this is null and `kind` is `start-url`.
- `finalUrl`: where the link ended up after redirects, when different from `linkUrl`.
- `element`, `kind`: the HTML tag and what it is (`link`, `image`, `script`, `stylesheet`, `iframe`, `media`, `icon`, `canonical`, or `link-tag` for other `<link>` tags such as hreflang alternates).
- `anchorText`: the link text, or the alt text for an image.
- `status`: the final HTTP status, or null when there was no HTTP answer (DNS, connection or TLS failure).

A summary for each site (pages scanned, links checked, broken, blocked and timed-out counts, any start-page error) is saved in the run's key-value store under `SUMMARY`.

### Pricing

$0.004 for each page scanned. A page is charged only when it loads as HTML on the site being scanned. Checking links costs nothing, and neither do pages that fail to load, non-HTML files or a second address for a page already scanned (such as /folder/ and /folder/index.html). A 100-page site costs $0.40. Set a maximum charge for the run and the checker stops scanning new pages when it is reached; links already found are still checked. Apify also charges $0.00005 each time a run starts (once per GB of memory; this actor's default is under 1 GB).

### Limits

- Pages are read as delivered by the server. Links that only appear after JavaScript runs aren't found.
- Links written as an IP address (public or private) are skipped, and so is any domain that resolves to a private, loopback or reserved address, or a redirect to one.
- Pages are scanned only when they are HTML. Only the first 3 MB of each page is read.
- Some servers treat a run of fast requests as an attack and start sending 403 or 429. Those links come back as `blocked`. Lower `concurrency` and run again if many links on one site come back that way.
- `mailto:`, `tel:`, `javascript:` and `#fragment` links aren't checked. A fragment is removed before the page is checked, so a missing anchor on a working page is not reported.

# Actor input Schema

## `startUrls` (type: `array`):

A domain (example.com) or a page URL. The checker starts there and follows links on the same site (www and non-www count as one site). Several sites can run in one go.

## `maxPagesPerSite` (type: `integer`):

Each scanned page is one charged event. 1 to 10,000.

## `maxDepth` (type: `integer`):

0 scans only the start page. 1 adds the pages it links to, and so on. 0 to 20.

## `onlyUnderStartPath` (type: `boolean`):

Start at example.com/blog/ and only /blog/ pages are scanned. Links to other parts of the site are still checked.

## `checkExternalLinks` (type: `boolean`):

Off: only links within the scanned site are checked. Links to other sites are not charged either way.

## `checkResources` (type: `boolean`):

Off: only page links (a and area tags) are checked. Images, scripts, stylesheets, iframes, audio, video, icons and canonical tags are skipped.

## `reportBlocked` (type: `boolean`):

HTTP 401, 403, 429 and 999, plus any error from social and marketplace sites that block checkers. These come back with verdict 'blocked' so you can check them by hand.

## `includeOkLinks` (type: `boolean`):

Off: only problem links are output. On: every link found, one row per page it appears on.

## `respectRobotsTxt` (type: `boolean`):

Pages your robots.txt disallows are not fetched. Turn off to check your own site's private sections.

## `maxLinkChecksPerSite` (type: `integer`):

A safety cap on unique links checked per site. Link checks are not charged. 10 to 50,000.

## `concurrency` (type: `integer`):

1 to 50. Never more than 5 at once to the site being scanned.

## `timeoutSecs` (type: `integer`):

5 to 60.

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

Optional. The User-Agent header sent with each request.

## Actor input object example

```json
{
  "startUrls": [
    "evenwork.co.uk"
  ],
  "maxPagesPerSite": 100,
  "maxDepth": 5,
  "onlyUnderStartPath": false,
  "checkExternalLinks": true,
  "checkResources": true,
  "reportBlocked": true,
  "includeOkLinks": false,
  "respectRobotsTxt": true,
  "maxLinkChecksPerSite": 5000,
  "concurrency": 10,
  "timeoutSecs": 15
}
```

# Actor output Schema

## `results` (type: `string`):

One row per problem link and the page it sits on: verdict, HTTP status, anchor text and reason.

## `summary` (type: `string`):

Pages scanned, links checked and counts by verdict, per site.

# 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 = {
    "startUrls": [
        "evenwork.co.uk"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("evenwork/broken-link-checker").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 = { "startUrls": ["evenwork.co.uk"] }

# Run the Actor and wait for it to finish
run = client.actor("evenwork/broken-link-checker").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 '{
  "startUrls": [
    "evenwork.co.uk"
  ]
}' |
apify call evenwork/broken-link-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,evenwork/broken-link-checker"
        }
    }
}
```

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/O5cT6Jf4v92eMXkEN/builds/AlcdwIa0wMXEKgVwv/openapi.json
