# Extract All Links From a Website: internal and external (`steadydata/page-links-extractor`) Actor

Extract all links from a website, up to 500 pages a run and 2,000 links per page: absolute URL, anchor text, internal or external, nofollow and rel, fragment and query flags, plus per page the counts of internal, external, nofollow, mailto and tel links. Robots-aware, no browser. Pay per link.

- **URL**: https://apify.com/steadydata/page-links-extractor.md
- **Developed by:** [Steadydata Team](https://apify.com/steadydata) (community)
- **Categories:** AI, SEO tools, Developer tools
- **Features:** Limited permissions
- **Stats:** 8 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.20 / 1,000 link listeds

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?

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

## Extract All Links From a Website: internal and external

Extract all links from a website, up to 500 pages a run and 2,000 links per page: absolute URL, anchor text, internal or external, nofollow and rel, target, scheme, fragment and query flags, plus per page the counts of internal, external, nofollow, mailto and tel links. Robots-aware, no browser. Pay per link.

### Why this scraper

- **Only delivered results are charged.** Inputs that fail come back as clear error
  records at no cost.
- One plain fetch per page, parsed with lxml, no browser and no start fee. Measured on the platform: 300 links from three pages (python.org, a Wikipedia article, BBC News) in 11 seconds for four tenths of a cent.
- Every link as a usable row: the absolute URL (relative hrefs and `<base>` resolved), anchor text (title or aria-label when the link is an image), internal or external by registered domain (docs.python.org counts as python.org, www.bbc.co.uk as bbc.co.uk), the full `rel` value with a nofollow flag, target, scheme, fragment and query flags, and how often the page links that URL.
- Page totals on every row: unique link count, internal, external, nofollow, mailto and tel counts, so a site audit reads off the first row per page.
- Robots-aware: each host's robots.txt is read once per run and a closed path comes back as a free `ROBOTS_DISALLOWED` row (measured: Google's `/search` path).

### Who this is for

Paste page URLs in `urls` (up to 500 per run), set `maxLinksPerPage` (default 500, ceiling 2,000, page order), choose `scope` (`all`, `internal` or `external`) and leave `uniqueOnly` on for one row per URL, or switch it off to see every link element. Built for internal-linking audits, outbound-link and nofollow checks, competitor link research, sitemap seeding and crawling pipelines that need the link graph of a page without a browser.

### Who this is not for

No browser is used, so links that a page adds with JavaScript after loading are not seen. Only `<a href>` links count; buttons, forms and links inside iframes are not. mailto: and tel: links are counted on the page row but never delivered as addresses. Internal versus external uses the registered domain with a short list of two-part suffixes (co.uk, com.au and the like), not the full public suffix list. A page that answers 403 or 429 comes back as a free `BLOCKED` row, a page without any link as a free `NO_LINKS` row.

### Input fields

| Field | Type | Required or default | What it does |
|---|---|---|---|
| `urls` | list of text | required | One per row, up to 500: full page URLs (https://...). Each host's robots.txt is respected. |
| `maxLinksPerPage` | number | 500 | Cost ceiling per page, in page order. |
| `scope` | text (all, internal, external) | all | all, internal (same registered domain) or external. |
| `uniqueOnly` | true/false | true | On: a URL linked several times on the page is delivered once, with the first anchor text and the number of occurrences. Off: every link element is a row. |

### Input example

```json
{
    "urls": [
        "https://www.python.org/",
        "https://en.wikipedia.org/wiki/Web_scraping"
    ],
    "maxLinksPerPage": 500,
    "scope": "all",
    "uniqueOnly": true
}
```

### Output example

| Field | Type | What it holds | Example |
|---|---|---|---|
| `pageUrl` | text | The page this link was found on. | `https://en.wikipedia.org/wiki/Web_scraping` |
| `position` | number | The place in the source's own order, counting from 1. | `1` |
| `url` | text | The address the link points to, made absolute. | `https://en.wikipedia.org/wiki/Main_Page` |
| `anchorText` | text | The clickable text of the link; empty on an image link. | `Main page` |
| `isInternal` | true/false | True when the link stays on the same domain. | `True` |
| `domain` | text | The domain the link points to. | `en.wikipedia.org` |
| `rel` | text | Filled when the link carries a rel attribute, for example nofollow or sponsored. |  |
| `isNofollow` | true/false | True when the link carries rel=nofollow and so passes no link value. | `False` |
| `target` | text | Filled when the link opens elsewhere, for example target=\_blank. |  |
| `scheme` | text | The scheme of the link: https, http, mailto or tel. | `https` |
| `hasFragment` | true/false | True when the link points at a spot inside a page, with a # in it. | `False` |
| `hasQuery` | true/false | True when the link carries a query string. | `False` |
| `occurrences` | number | How often this same link stands on the page. | `2` |
| `pageTitle` | text | The title of the page the link was found on. | `Web scraping - Wikipedia` |
| `pageLinkCount` | number | How many links the page holds in total. | `327` |
| `pageInternalCount` | number | How many of those stay on the same domain. | `247` |
| `pageExternalCount` | number | How many point to another domain. | `80` |
| `pageNofollowCount` | number | How many carry rel=nofollow. | `64` |
| `pageMailtoCount` | number | How many are mail links. |  |
| `pageTelCount` | number | How many are telephone links. |  |

Error codes: `INVALID_URL`, `ROBOTS_DISALLOWED`, `NOT_HTML`, `NO_LINKS`, `FETCH_FAILED`, `BLOCKED`.

One delivered row looks like this:

```json
{
  "pageUrl": "https://www.python.org/",
  "position": 1,
  "url": "https://www.python.org/",
  "anchorText": "Python",
  "isInternal": true,
  "domain": "www.python.org",
  "rel": null,
  "isNofollow": false,
  "target": null,
  "scheme": "https",
  "hasFragment": false,
  "hasQuery": false,
  "occurrences": 2,
  "pageTitle": "Welcome to Python.org",
  "pageLinkCount": 129,
  "pageInternalCount": 86,
  "pageExternalCount": 43,
  "pageNofollowCount": 0,
  "pageMailtoCount": 0,
  "pageTelCount": 0,
  "status": "ok"
}
```

### Related actors from steadydata

- [page-images-extractor](https://apify.com/steadydata/page-images-extractor): the images of the same page, with alt text
- [url-status-redirect-checker](https://apify.com/steadydata/url-status-redirect-checker): the status of every link you found
- [sitemap-urls](https://apify.com/steadydata/sitemap-urls): every URL of the site, from its sitemaps

### Pricing

Pay per event: one `link-listed` event per delivered result. No charge for inputs
that fail, no separate platform-usage surcharge.

**Free Apify plan:** this actor delivers up to 25 rows per run for accounts on the Apify free
plan, and then stops with a message. That limit is set by us, not by Apify. It exists so the
actor keeps paying for itself for the people who do pay. Any paid Apify plan runs it at full
size, billed per delivered row, with failed rows never charged.

**Reviews:** if this actor saves you time, a short review on this page is the one thing that
helps most. Ratings are what other buyers look at first, and we have no other way to ask.

### Use with AI agents

AI assistants such as Claude, ChatGPT or Cursor can run this actor through Apify's own MCP server. Ask for the actor `steadydata/page-links-extractor` by its full name, so the assistant does not pick a different one, and start from this minimal input:

```json
{
  "urls": [
    "https://www.python.org/",
    "https://en.wikipedia.org/wiki/Web_scraping"
  ]
}
```

The assistant can read the price per event from the Pricing section above before the first paid run. Failed input comes back as an error row, as described above.

### FAQ

**Is personal data collected?**
No. Links and anchor texts are what the page publishes; e-mail addresses and phone numbers behind mailto: and tel: links are counted, not delivered.

**Does it check whether the links work?**
No, it lists them. Feed the `url` column to the URL status and redirect checker below for status codes and redirect chains.

**How does `uniqueOnly` change the count?**
On, a URL linked five times is one row with `occurrences` 5 and the first non-empty anchor text; `pageLinkCount` is the number of unique URLs. Off, every link element is its own row.

**Can it crawl a whole site?**
Not by itself: it reads the pages you give it. Combine it with the sitemap URLs actor to get every page, then run this actor on those URLs.

**What does a run cost when a page fails?**
Nothing. `ROBOTS_DISALLOWED`, `NOT_HTML`, `NO_LINKS`, `FETCH_FAILED`, `INVALID_URL` and `BLOCKED` rows are free; only delivered links are charged.

**What happens when the source changes?**
Sources change from time to time; that is the nature of this work. The actor is
monitored daily and fixed fast, and while it is broken you are not charged, because
only delivered results cost anything.

**Can I call it from my own code, like an API?**
Yes. Every run is available through the Apify API: start it with one HTTP request, then read
the results as JSON, CSV or Excel from the dataset endpoint, or use the official Python and
JavaScript clients. The input is the same JSON as in the input example above, so a scheduled
script, a Make or Zapier step or an AI agent can call it without any changes.

# Changelog

This Actor's version history is a separate document: https://apify.com/steadydata/page-links-extractor/changelog.md

# Actor input Schema

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

One per row, up to 500: full page URLs (https://...). Each host's robots.txt is respected.

## `maxLinksPerPage` (type: `integer`):

Cost ceiling per page, in page order.

## `scope` (type: `string`):

all, internal (same registered domain) or external.

## `uniqueOnly` (type: `boolean`):

On: a URL linked several times on the page is delivered once, with the first anchor text and the number of occurrences. Off: every link element is a row.

## Actor input object example

```json
{
  "urls": [
    "https://www.python.org/",
    "https://en.wikipedia.org/wiki/Web_scraping"
  ],
  "maxLinksPerPage": 500,
  "scope": "all",
  "uniqueOnly": 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 = {
    "urls": [
        "https://www.python.org/",
        "https://en.wikipedia.org/wiki/Web_scraping"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("steadydata/page-links-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 = { "urls": [
        "https://www.python.org/",
        "https://en.wikipedia.org/wiki/Web_scraping",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("steadydata/page-links-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 '{
  "urls": [
    "https://www.python.org/",
    "https://en.wikipedia.org/wiki/Web_scraping"
  ]
}' |
apify call steadydata/page-links-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,steadydata/page-links-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/oXHdbhVqg6q6blBsU/builds/y0u4J3zBpUjKDxMBW/openapi.json
