# Website Link Extractor (`mina_safwat/website-link-extractor`) Actor

Extracts every link from any website — internal, external, documents and media — with anchor text and the page it was found on

- **URL**: https://apify.com/mina\_safwat/website-link-extractor.md
- **Developed by:** [Mina](https://apify.com/mina_safwat) (community)
- **Categories:** Developer tools, Automation, SEO tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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 Link Extractor

### What does Website Link Extractor do?

**Give it any website and it returns every link on it** — where each link points, the text it was written as, whether it stays on the site or leads elsewhere, and which page it was found on.

Paste a domain, press Start, and download the result as JSON, CSV or Excel — or pull it straight from the Apify API.

### Why use Website Link Extractor?

- **Audit a site** — get a complete map of its pages in one run.
- **Find broken or unwanted links** — export everything and check it in a spreadsheet.
- **See who a site links to** — collect its outbound links to partners, sources or competitors.
- **Collect documents** — pull every PDF or spreadsheet a site publishes.
- **Feed another tool** — the links come out as a clean list, ready to hand to another scraper.

### How to use Website Link Extractor

1. Enter one or more **websites or pages**. A bare domain like `example.com` is fine.
2. Set **Maximum pages to read** and **How deep to follow links**.
3. Optionally choose **Which links to return** — all, internal only, or external only.
4. Click **Start**, then open the **Output** tab when it finishes.

### Input

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| **Websites or pages** (`start_urls`) | array | Yes | Where to start. |
| **Maximum pages to read** (`max_pages`) | integer | No | How many pages to visit per site. Default 20. |
| **How deep to follow links** (`max_depth`) | integer | No | 0 reads only the page given, 1 also reads pages linked from it. Default 1. |
| **Which links to return** (`link_scope`) | select | No | `all`, `internal` or `external`. Default all. |
| **Stay on the same website while crawling** (`stay_on_site`) | boolean | No | Controls which pages are visited, not which links are returned. On by default. |
| **Only include links matching** (`include_pattern`) | string | No | Optional regular expression, e.g. `/blog/`. |
| **Exclude links matching** (`exclude_pattern`) | string | No | Optional regular expression, e.g. `\?utm_`. |
| **Proxy configuration** (`proxyConfiguration`) | object | No | Optional. Most sites need no proxy. |

Example input:

```json
{
  "start_urls": ["https://www.python.org"],
  "max_pages": 20,
  "max_depth": 1,
  "link_scope": "external"
}
```

### Output

One row per unique link found:

```json
{
  "url": "https://pypi.org/",
  "text": "PyPI",
  "type": "page",
  "is_internal": false,
  "domain": "pypi.org",
  "found_on": "https://www.python.org/",
  "depth": 0,
  "rel": null,
  "source_site": "https://www.python.org/"
}
```

You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

#### Data fields

| Field | Description |
| --- | --- |
| `url` | Where the link points. |
| `text` | The clickable text of the link. |
| `type` | `page`, `document`, `image` or `media`, based on what it points at. |
| `is_internal` | `true` if it stays on the same site. |
| `domain` | The domain it points to, handy for grouping outbound links. |
| `found_on` | The page the link was found on. |
| `depth` | How many clicks from the starting page that page was. |
| `rel` | The link's `rel` attribute, such as `nofollow`, when it has one. |
| `source_site` | Which of your start URLs this came from. |

### What to expect

Each unique destination is returned once, no matter how many times it appears — a link in the header of every page gives you one row, not one per page. Anchors, `mailto:` and `javascript:` links are not included, since they are not pages.

### How much does it cost to extract links?

Very little. Six pages of python.org produced 317 links in fourteen seconds and cost under two tenths of a cent.

### Tips

- **Start with depth 1.** It covers a site's main navigation. Raise it only if you need to go deeper.
- **Use `link_scope: external`** to see everywhere a site sends its visitors.
- **Use the exclude pattern** to drop tracking URLs, for example `\?utm_`.

### FAQ and support

**Why do I get fewer links than I expected?** Each destination is listed once. Raise Maximum pages or How deep to follow links to cover more of the site.

**Does it find links added by JavaScript?** It reads the HTML a site serves. Links that only appear after scripts run may not be included.

**Is scraping links legal?** This Actor collects only publicly available data. You are responsible for how you use it, and you should respect the terms of the sites you crawl. If in doubt, take legal advice.

Found a bug, or need a field that is not here? Open an issue on the **Issues** tab.

### SEO Keywords

website link extractor, extract all links from a website, url crawler, internal and external link scraper, broken link audit data, site structure crawler, anchor text extractor, seo link audit, sitemap discovery tool, web crawler for links

# Actor input Schema

## `start_urls` (type: `array`):

Where to start. A domain on its own is fine, e.g. example.com.

## `max_pages` (type: `integer`):

How many pages to visit per website.

## `max_depth` (type: `integer`):

0 reads only the page you give it, 1 also reads pages linked from it, and so on.

## `link_scope` (type: `string`):

All links, only those on the same site, or only those pointing elsewhere.

## `stay_on_site` (type: `boolean`):

Leave on to follow only same-site links. This controls which pages are visited, not which links are returned.

## `include_pattern` (type: `string`):

Optional regular expression. Only links whose address matches are returned, e.g. /blog/

## `exclude_pattern` (type: `string`):

Optional regular expression. Links whose address matches are dropped, e.g. ?utm\_

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

Optional. Most sites need no proxy at all.

## Actor input object example

```json
{
  "start_urls": [
    "https://www.python.org"
  ],
  "max_pages": 20,
  "max_depth": 1,
  "link_scope": "all",
  "stay_on_site": true
}
```

# Actor output Schema

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

No description

# 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 = {
    "start_urls": [
        "https://www.python.org"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mina_safwat/website-link-extractor").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 = { "start_urls": ["https://www.python.org"] }

# Run the Actor and wait for it to finish
run = client.actor("mina_safwat/website-link-extractor").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 '{
  "start_urls": [
    "https://www.python.org"
  ]
}' |
apify call mina_safwat/website-link-extractor --silent --output-dataset

```

## MCP server setup

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

```

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/aglZvakYx9akcy8zf/builds/za8QfYQxggisIvbDn/openapi.json
