# VK Keyword Hit Search (`chloechen1688/vk-keyword-hit-search`) Actor

Search public VK posts by keyword, then keep comments on those posts that hit the same keywords, and export a styled Excel file.

- **URL**: https://apify.com/chloechen1688/vk-keyword-hit-search.md
- **Developed by:** [chloe chen](https://apify.com/chloechen1688) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.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.

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

### What does VK Keyword Hit Search do?

**VK Keyword Hit Search** reads the public [VK](https://vk.com/) news feed for the keywords and dates you provide, then keeps comments on those posts that contain the same keywords. It stores one dataset row per hit and a styled Excel workbook. It does not log in as a VK user, does not read private profiles, and does not search every comment on VK. Comments are loaded only from posts that already matched.

The Actor calls the official VK API methods `newsfeed.search` and `wall.getComments`. A **service access token** with permission to use those methods is required. A VK ID user token limited to personal info cannot search the news feed.

### Why use VK Keyword Hit Search?

VK has no single endpoint that searches comments across the whole site. This Actor does the two-step collection in one run:

- Search posts in a required time range, newest first.
- Open comments only on posts that matched, and keep a comment only when its text matches too.
- Treat `OR` as separate searches whose posts are merged by link.
- Treat `AND`, commas, Chinese commas, semicolons, and spaces as “every term must appear”.
- Stop a page loop when VK returns a short page or no next page, instead of requesting empty pages.
- Always write the Excel file, including a header-only workbook when nothing matched.
- Leave the run private until you choose to publish it. Scheduling, the Apify API, and dataset exports stay available on a private Actor.

### What data can VK Keyword Hit Search extract?

| Field | Type | Description |
| --- | --- | --- |
| 日期 | text | Publish time in Asia/Shanghai |
| 类型 | text | 帖子, 转发, or 评论 |
| 内容 | text | Post or comment text returned by the API, with HTML tags removed |
| 链接 | link | `https://vk.com/wall{owner}_{post}` or the same URL with `?reply=` |
| 作者 | text | User or community name |
| 作者主页 | link | Public VK profile or community page |
| 粉丝数 | number | Followers for a user, or members for a community |
| 点赞 / 评论数 / 转发 / 互动总数 | number | Counts from the API. For a comment, 评论数 is the reply count |
| 平台 | text | Always `VK` |

The API text is the body. The Actor does not open each post in a browser to fetch another copy.

### How to scrape VK posts and comments

1. Open the Actor and set the secret environment variable `SKILL_VK_ACCESS_TOKEN` to a VK service token. Do not put the token in the input.
2. Optional: set `SKILL_VK_PROXY` when this machine cannot reach `api.vk.com` directly.
3. Open **Input**. Enter keywords, a start date, and an end date.
4. Leave post pages and comment pages at 10 unless you want a shorter sample. The Actor stops early when a page is empty or shorter than requested.
5. Start the run. Open **Output** for the Excel file `results.xlsx`, or download the dataset as JSON, CSV, or Excel.
6. Read the `OUTPUT` record for the match mode, row counts, suggested file name, and warnings.

### How much will it cost to scrape VK?

This Actor is private and has no Store price. A run spends Apify compute units for the time the container is alive, plus your own VK API quota. VK documents `newsfeed.search` as usable with a user token or a service key and caps a single search at the first 1000 results. Comment collection is the larger part: each matched post can request up to 10 pages of 100 comments. Lower `pages` and `comment_pages` when you only need a sample. Publishing later can use pay per usage or pay per event; the platform fee on paid Actors is separate from VK, which does not charge for these read methods.

### Input

See the Input tab for every field. `query`, `start_time`, and `end_time` are required.

`самокат AND segway` keeps an item only when both words appear. `camokat OR segway` searches each word and unions the posts. A comma is `AND`, not `OR`. Dates without a time are Asia/Shanghai: the start date begins at 00:00:00 and the end date finishes at 23:59:59. If you omit the VK time arguments yourself, VK would silently search only the last 24 hours; this Actor refuses to run without both dates.

The token is not an input. Add `SKILL_VK_ACCESS_TOKEN` under the Actor's environment variables and mark it **Secret**.

### Output

You can download the dataset in JSON, HTML, CSV, or Excel. The styled workbook is the key-value record `results.xlsx`. A summary JSON record is stored as `OUTPUT`.

```json
{
  "日期": "2026-10-16 22:10:53",
  "类型": "帖子",
  "内容": "public post text",
  "链接": "https://vk.com/wall-170492840_23573",
  "作者": "Community name",
  "作者主页": "https://vk.com/club170492840",
  "粉丝数": 1000,
  "点赞": 3,
  "评论数": 1,
  "转发": 0,
  "互动总数": 4,
  "平台": "VK"
}
```

### Tips

Use one page of posts and one page of comments for the first run, then raise both toward the default of 10. `OR` multiplies post searches, so a long date range with several `OR` groups takes longer. A warning that comments exceeded the page cap means that post has more comments than the run scanned; matches outside those pages are not included.

### FAQ, disclaimers, and support

#### Which VK token works?

`newsfeed.search` accepts a user access token or a service key. Tokens issued for personal info only are rejected by VK. Create the token in the VK app settings and store it as a Secret. The Actor never writes it into the dataset or the Excel file.

#### Does a comma mean OR?

No. A comma, Chinese comma, semicolon, or space means every term must appear. Use the word `OR` with spaces around it when you want separate searches and a union.

#### Is the text the full post body?

Yes. The text fields from `newsfeed.search` and `wall.getComments` are stored as 内容. There is no second request for a different article body.

Our Actors are ethical and do not extract any private user data, such as email addresses, gender, or location. They only extract what the user has chosen to share publicly. We therefore believe that our Actors, when used for ethical purposes by Apify users, are safe. However, you should be aware that your results could contain personal data. Personal data is protected by the GDPR in the European Union and by other regulations around the world. You should not scrape personal data unless you have a legitimate reason to do so. If you're unsure whether your reason is legitimate, consult your lawyers.

Questions about a run can go to the Actor's Issues tab. Programmatic runs use the API tab on this Actor.

# Actor input Schema

## `query` (type: `string`):

AND, a comma, a Chinese comma, a semicolon, or a space means every term must appear in the same post or comment. OR runs a separate search for each side and keeps the union. Example: camokat OR segway.

## `start_time` (type: `string`):

YYYY-MM-DD, read as 00:00:00 Asia/Shanghai. YYYY-MM-DD HH:MM:SS and Unix seconds are also accepted.

## `end_time` (type: `string`):

YYYY-MM-DD, read as 23:59:59 Asia/Shanghai. YYYY-MM-DD HH:MM:SS and Unix seconds are also accepted.

## `pages` (type: `integer`):

How many newsfeed.search pages to request per keyword group. The run stops early when VK has no further page.

## `count` (type: `integer`):

Posts requested on each newsfeed.search page.

## `comment_pages` (type: `integer`):

How many comment pages to scan on each matched post. The run stops early when a post has no further comments.

## `comment_count` (type: `integer`):

Comments requested on each wall.getComments page.

## `filename` (type: `string`):

Optional download name recorded in the run summary. The stored key is always results.xlsx.

## Actor input object example

```json
{
  "query": "camokat OR segway",
  "start_time": "2026-10-01",
  "end_time": "2026-10-19",
  "pages": 10,
  "count": 100,
  "comment_pages": 10,
  "comment_count": 100
}
```

# Actor output Schema

## `excel` (type: `string`):

No description

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

No description

## `summary` (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 = {
    "query": "camokat OR segway",
    "start_time": "2026-10-01",
    "end_time": "2026-10-19"
};

// Run the Actor and wait for it to finish
const run = await client.actor("chloechen1688/vk-keyword-hit-search").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 = {
    "query": "camokat OR segway",
    "start_time": "2026-10-01",
    "end_time": "2026-10-19",
}

# Run the Actor and wait for it to finish
run = client.actor("chloechen1688/vk-keyword-hit-search").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 '{
  "query": "camokat OR segway",
  "start_time": "2026-10-01",
  "end_time": "2026-10-19"
}' |
apify call chloechen1688/vk-keyword-hit-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,chloechen1688/vk-keyword-hit-search"
        }
    }
}
```

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/99QQMyaWcShdRWsrn/builds/augb7fbXKA3DntWDS/openapi.json
