# WeChat Article Comments Scraper — 公众号文章评论 + 回复抓取 (`opspilot.cc/wechat-article-comments-scraper`) Actor

EN — Pull public comments and reply threads from a WeChat Official Account article. mode=comments for top-level comments only; mode=with-replies adds per-comment reply chains. Free users: 5 runs/day. ZH — 抓取公众号文章公开评论 + 回复链。mode=comments 只拉一级评论;mode=with-replies 拉一级 + 二级回复。

- **URL**: https://apify.com/opspilot.cc/wechat-article-comments-scraper.md
- **Developed by:** [wang wei](https://apify.com/opspilot.cc) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.08 / actor start

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

## WeChat Article Comments Scraper

EN — Pull public comments and reply threads from any WeChat Official Account article. `mode=comments` returns top-level comments only (cheapest); `mode=with-replies` adds per-comment reply chains (one extra upstream call per comment that has replies).

ZH — 抓取任意公众号文章的公开评论和回复链。`mode=comments` 只返回一级评论(最便宜);`mode=with-replies` 在每条有回复的评论下追加二级回复链(每条需要时多 1 次上游调用)。

- **Console**: https://console.apify.com/actors/ier1jWLNCkvLh8vpS
- **Short link**: opspilot.cc/wechat-article-comments-scraper

***

### When to use this Actor

| Goal | Actor |
|---|---|
| List every article on an account | [WeChat Account Articles Scraper](https://console.apify.com/actors/vxAjW6anQJQWk7xTF) |
| Read a single article's full body + author | [WeChat Article Detail Scraper](https://console.apify.com/actors/5vrr8dBcnclIva0Lx) |
| Read the account's profile (IP region, original count, ban status) | [WeChat Account Profile Scraper](https://console.apify.com/actors/3JV499ECEjb5un854) |
| Pull interaction metrics (read / like / share) | [WeChat Article Metrics Scraper](https://console.apify.com/actors/y3ZqhBdIY2LzGtkVK) |
| **Pull comments + reply threads (this Actor)** | — |
| Search across all of WeChat | [WeChat Universal Search Scraper](https://console.apify.com/actors/search) |

***

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `url` | string | `https://mp.weixin.qq.com/s/TSNQKkRpN1qbKsT7BvzqIw` | Article URL. Short (`/s/<sn>`) and long (`/s?__biz=...&mid=...`) forms accepted. |
| `mode` | string | `"comments"` | `comments` = top-level only. `with-replies` = comments + reply chains (1 extra upstream call per comment that has replies). |
| `commentId` | string | `""` | Pre-known comment\_id from `/fetch_article_detail` response's `commentId`. Speeds up upstream by skipping HTML pre-fetch. Leave empty to let upstream fetch the article HTML. |
| `maxComments` | int | `100` | Hard cap on total comments pulled across paginated requests. 1-500. |
| `maxReplies` | int | `50` | Hard cap on replies per comment (mode=with-replies). 1-200. |
| `raw` | string | `"false"` | `false` = omit raw upstream payload; `true` = attach `rawData` for debugging. |

#### Where to get a URL

- From the [Article Detail Scraper](https://console.apify.com/actors/5vrr8dBcnclIva0Lx): pass any URL, get back `commentId` + body.
- From the [Account Articles Scraper](https://console.apify.com/actors/vxAjW6anQJQWk7xTF): each row's `url` field.

***

### Output (one row per Actor run)

```json
{
  "url": "https://mp.weixin.qq.com/s/TSNQKkRpN1qbKsT7BvzqIw",
  "mode": "with-replies",
  "commentId": "3884868893382230017",
  "appmsgId": "2247780992",
  "totalCount": 28,
  "electedTotal": 22,
  "fetchedCount": 10,
  "hasMore": false,
  "continueFlag": 0,
  "commentsPages": 1,
  "comments": [
    {
      "contentId": "921450079049482451",
      "nickName": "IFGSLL",
      "content": "懂了，这就下单 4070TI",
      "likeNum": 20,
      "createTime": 1741148721,
      "ipRegion": { "country": "中国", "province": "江苏", "city": "" },
      "ipIds":    { "country": "156", "province": "", "city": "" },
      "isElected": 1,
      "isTop": 0,
      "identityName": "oHQDtwGndOC9slgFqApFtbjJEdxk",
      "replyTotal": 1,
      "replies": [
        {
          "replyId": "2",
          "nickName": "🦄Savior",
          "content": "还没降价，再等等",
          "createTime": 1741149962,
          "ipRegion": { "country": "中国", "province": "河南", "city": "" },
          "ipIds":    { "country": "156", "province": "", "city": "" },
          "identityName": "oHQDtwJjKLALca6GJyICQCRhAvKg",
          "fromAi": 0,
          "replyIsElected": null
        }
      ]
    }
  ],
  "collectedAt": "2026-09-16T12:00:00.000Z"
}
```

**Field notes**

- `totalCount` / `electedTotal` come from the upstream's first response (total in the system). `fetchedCount` is how many made it into this run (≤ `maxComments`).
- `contentId` / `replyId` / `commentId` / `appmsgId` are always strings (big-integer safe per JSON serialization rules).
- `ipRegion` is the human-readable form (`country_name / province_name / city_name`); `ipIds` carries the parallel numeric codes (`country_id / province_id / city_id`).
- `replies` is `[]` when `mode=comments` even if `replyTotal > 0`. Use `mode=with-replies` to fetch them.
- `hasMore=true` means upstream still has more comments / replies beyond `maxComments` / `maxReplies`. Re-run with higher caps to drain.

***

### How to run

1. **Console**: paste any article URL (or use the default) and click Start.
2. **API**:
   ```bash
   curl -X POST "https://api.apify.com/v2/acts/ier1jWLNCkvLh8vpS/runs?waitForFinish=60" \
     -H "Authorization: Bearer <APIFY_TOKEN>" \
     -H "Content-Type: application/json" \
     -d '{"url":"https://mp.weixin.qq.com/s/...", "mode":"with-replies"}'
   ```
3. **CLI**:
   ```bash
   apify call wechat-article-comments-scraper \
     -i '{"url":"https://mp.weixin.qq.com/s/...", "mode":"with-replies", "maxComments":200}'
   ```

Free users: 5 runs/day. Paid users: 1 PPE event per upstream page (`article-comments-result`).

***

### Use it together with the other WeChat Actors

| Where in the pipeline | Actor | Console |
|---:|---|---|
| step ① listing | [Account Articles Scraper](https://console.apify.com/actors/vxAjW6anQJQWk7xTF) | …/vxAjW6anQJQWk7xTF |
| step ② detail | [Article Detail Scraper](https://console.apify.com/actors/5vrr8dBcnclIva0Lx) | …/5vrr8dBcnclIva0Lx |
| step ③ metrics | [Article Metrics Scraper](https://console.apify.com/actors/y3ZqhBdIY2LzGtkVK) | …/y3ZqhBdIY2LzGtkVK |
| **step ④ comments (you are here)** | **Article Comments Scraper** | **…/ier1jWLNCkvLh8vpS** |
| step ① profile (alt) | [Account Profile Scraper](https://console.apify.com/actors/3JV499ECEjb5un854) | …/3JV499ECEjb5un854 |

**You are here:** **Article Comments Scraper** (step ④) — pair it with an Article Detail / Metrics output for the URL, or pass any URL you already have.

***

### Pricing

PPE: 1 event per upstream page fetched. `article-comments-result` event is charged with count = (comments pages) + (reply batches). Mode `comments` typically produces 1-3 PPE per run; mode `with-replies` produces (comments pages) + (number of comments with replies) PPE per run.

***

### Tests

```bash
npm test
```

Runs unit assertions (input validation, body shape, normalize across `comments` / `with-replies` / `raw=true` / `raw=false`, §98 string coercion, ip\_wording flattening, null handling) plus 9 integration scenarios (mock fetch drives the full `run()` flow including default/with-replies modes, commentId forwarding, maxComments cap, free-tier gating, upstream errors).

```
✅ unit.js: all assertions passed.
integration.js: 9 scenarios passed.
```

# Changelog

This Actor's version history is a separate document: https://apify.com/opspilot.cc/wechat-article-comments-scraper/changelog.md

# Actor input Schema

## `url` (type: `string`):

WeChat Official Account article URL. Accepts short (https://mp.weixin.qq.com/s/...) and long (with \_\_biz / mid / idx / sn / chksm) forms. Exactly 1 per run.

## `mode` (type: `string`):

comments = top-level comments only. with-replies = comments + per-comment reply chains (extra upstream call per comment that has reply\_total>0).

## `commentId` (type: `string`):

Optional 1-32 digit comment\_id from /fetch\_article\_detail response's commentId field. Speeds up the upstream call by skipping the HTML pre-fetch. Leave empty to let upstream fetch the article HTML itself.

## `maxComments` (type: `integer`):

Hard cap on how many top-level comments to pull across paginated requests. 1-500. Default 100.

## `maxReplies` (type: `integer`):

Hard cap on replies per comment when mode=with-replies. 1-200. Default 50.

## `raw` (type: `string`):

Attach unprocessed upstream payloads as rawData. Default false keeps datasets small.

## Actor input object example

```json
{
  "url": "https://mp.weixin.qq.com/s/TSNQKkRpN1qbKsT7BvzqIw",
  "mode": "comments",
  "commentId": "",
  "maxComments": 100,
  "maxReplies": 50,
  "raw": "false"
}
```

# Actor output Schema

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

Each pushed item contains comments + (when mode=with-replies) replies for one article URL.

## `summary` (type: `string`):

Article URL, mode, total/elected/fetched counts, comments pages, reply batches, tier.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("opspilot.cc/wechat-article-comments-scraper").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("opspilot.cc/wechat-article-comments-scraper").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 '{}' |
apify call opspilot.cc/wechat-article-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,opspilot.cc/wechat-article-comments-scraper"
        }
    }
}
```

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/ier1jWLNCkvLh8vpS/builds/fQLeiRzSf2mHuHHfA/openapi.json
