# Keywords Extractor (`lukaskrivka/keywords-extractor`) Actor

Use our free website keyword extractor to crawl any website and extract keyword counts on each page.

- **URL**: https://apify.com/lukaskrivka/keywords-extractor.md
- **Developed by:** [Lukáš Křivka](https://apify.com/lukaskrivka) (community)
- **Categories:** Other, Open source
- **Stats:** 847 total users, 5 monthly users, 100.0% runs succeeded, 15 bookmarks
- **User rating**: 4.78 out of 5 stars

## 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/platform/actors/running/actors-in-store#pay-per-usage

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

### Keyword Extractor

Can deeply crawl a website and counts how many times are provided keywords found on the page.

#### How to use

- You can pass in any number of keywords that you want to count.
- You can combine Start URLs, Pseudo Urls and link selector to traverse any number of pages accross websites. Check our [scraping tutorial](https://docs.apify.com/scraping) on how to use these.
- You can specify `maxDepth` and `maxPagesPerCrawl` to limit the scope of the scrape. Start URLs have depth 0. So if you want just the start URLs, set `maxDepth` to 0, etc.
- You can pick case sensitive search and search through scripts.
- You can choose to scrape with or without browser. Browser is more expensive but allows JavaScript rendering and waiting.
- For browser, you can use many additional features

#### How are keywords determined

The text is split into words by [word boundaries](https://www.regular-expressions.info/wordboundaries.html). Each word is then compared with each keyword. In the future, we may add other types of boundaries to choose from.

#### Example Output

For `keywords`:

```
["watch", "watches", "rolex"]
```

starting on `https://www.chrono24.com/watches/mens-watches--62.htm`

```
[
    {
        "url": "https://www.chrono24.com/watches/mens-watches--62.htm",
        "depth": 0,
        "result": {
            "watch": 63,
            "watches": 81,
            "rolex": 57
        }
    },
    {
        "url": "https://www.chrono24.com/user/index.htm",
        "depth": 1,
        "result": {
            "watch": 9,
            "watches": 13,
            "rolex": 1
        }
    },
    {
        "url": "https://www.chrono24.com/info/watch-collection.htm",
        "depth": 1,
        "result": {
            "watch": 56,
            "watches": 23,
            "rolex": 1
        }
    },
...
]
```

# Actor input Schema

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

A static list of URLs to scrape. To be able to add new URLs on the fly, enable the <b>Use request queue</b> option.<br><br>For details, see <a href='https://apify.com/apify/web-scraper#start-urls' target='_blank' rel='noopener'>Start URLs</a> in README.

## `useBrowser` (type: `boolean`):

If on, it will use regular borwser for scraping.

## `keywords` (type: `array`):

List of keywords to search and count on every page

## `caseSensitive` (type: `boolean`):

If on, it will only match keywords with exact upper or lower case.

## `scanScripts` (type: `boolean`):

If on, it will also count keywords appearing inside scripts.

## `linkSelector` (type: `string`):

A CSS selector saying which links on the page (<code>\<a></code> elements with <code>href</code> attribute) shall be followed and added to the request queue. This setting only applies if <b>Use request queue</b> is enabled. To filter the links added to the queue, use the <b>Pseudo-URLs</b> setting.<br><br>If <b>Link selector</b> is empty, the page links are ignored.<br><br>For details, see <a href='https://apify.com/apify/web-scraper#link-selector' target='_blank' rel='noopener'>Link selector</a> in README.

## `pseudoUrls` (type: `array`):

Specifies what kind of URLs found by <b>Link selector</b> should be added to the request queue. A pseudo-URL is a URL with regular expressions enclosed in <code>\[]</code> brackets, e.g. <code>http://www.example.com/\[.\*]</code>. This setting only applies if the <b>Use request queue</b> option is enabled.<br><br>If <b>Pseudo-URLs</b> are omitted, the actor enqueues all links matched by the <b>Link selector</b>.<br><br>For details, see <a href='https://apify.com/apify/web-scraper#pseudo-urls' target='_blank' rel='noopener'>Pseudo-URLs</a> in README.

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

How many links deep from the Start URLs do you want to crawl. Start URLs have depth 0.

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

Specifies proxy servers that will be used by the scraper in order to hide its origin.<br><br>For details, see <a href='https://apify.com/apify/web-scraper#proxy-configuration' target='_blank' rel='noopener'>Proxy configuration</a> in README.

## `maxPagesPerCrawl` (type: `integer`):

The maximum number of pages that the scraper will load. The scraper will stop when this limit is reached. It's always a good idea to set this limit in order to prevent excess platform usage for misconfigured scrapers. Note that the actual number of pages loaded might be slightly higher than this value.<br><br>If set to <code>0</code>, there is no limit.

## `maxConcurrency` (type: `integer`):

Specified the maximum number of pages that can be processed by the scraper in parallel. The scraper automatically increases and decreases concurrency based on available system resources. This option enables you to set an upper limit, for example to reduce the load on a target website.

## `retireInstanceAfterRequestCount` (type: `integer`):

How often will the browser itself rotate. Pick higher for smaller consumption, pick less to rotate (test) more proxies

## `useChrome` (type: `boolean`):

Only works for puppeteer type. Be careful that Chrome is not guaranteed to work with Puppeteer.

## `waitFor` (type: `string`):

Only works for puppeteer type. Will wait on each page. You can provide number in ms or a selector.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://apify.com"
    }
  ],
  "useBrowser": false,
  "keywords": [
    "apify",
    "web",
    "scraping",
    "automation"
  ],
  "caseSensitive": false,
  "scanScripts": false,
  "linkSelector": "a[href]",
  "pseudoUrls": [
    {
      "purl": "https://apify.com/[.*]"
    }
  ],
  "maxDepth": 5,
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "maxPagesPerCrawl": 100,
  "maxConcurrency": 50,
  "retireInstanceAfterRequestCount": 50,
  "useChrome": false
}
```

# 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": [
        {
            "url": "https://apify.com"
        }
    ],
    "keywords": [
        "apify",
        "web",
        "scraping",
        "automation"
    ],
    "linkSelector": "a[href]",
    "pseudoUrls": [
        {
            "purl": "https://apify.com/[.*]"
        }
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("lukaskrivka/keywords-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 = {
    "startUrls": [{ "url": "https://apify.com" }],
    "keywords": [
        "apify",
        "web",
        "scraping",
        "automation",
    ],
    "linkSelector": "a[href]",
    "pseudoUrls": [{ "purl": "https://apify.com/[.*]" }],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("lukaskrivka/keywords-extractor").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 '{
  "startUrls": [
    {
      "url": "https://apify.com"
    }
  ],
  "keywords": [
    "apify",
    "web",
    "scraping",
    "automation"
  ],
  "linkSelector": "a[href]",
  "pseudoUrls": [
    {
      "purl": "https://apify.com/[.*]"
    }
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call lukaskrivka/keywords-extractor --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/fgCg268Rg9Yrvrx24/builds/irvxpoDkPfnbazYNZ/openapi.json
