# 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
- **Features:** Limited permissions
- **Stats:** 857 total users, 1 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/actors/running/actors-in-store.md#pay-per-usage

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

### 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(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": [
    {
      "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": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,lukaskrivka/keywords-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/fgCg268Rg9Yrvrx24/builds/irvxpoDkPfnbazYNZ/openapi.json
