# WeChat Article Metrics Scraper — 公众号文章阅读/点赞/分享/收藏数 (`opspilot.cc/wechat-article-metrics-scraper`) Actor

EN — Fetch WeChat article metrics: read/like/share/collect/comment/star counts. default returns full; h5 is fast path (comments + elected comments). Free users: 5 runs/day. ZH — 公众号文章互动数据:阅读/点赞/分享/收藏/评论/星标数。default 全量,h5 仅评论数+精选评论数。

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

## Pricing

$0.06 / 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 Metrics Scraper

EN — Fetch public interaction metrics for any WeChat Official Account article. Returns read count, like count, share count, collect count, comment count, and star count. Two engines: `default` returns full metrics; `h5` is a fast path that returns only `comment_count` and `elected_comment_count`, with an optional pre-known `comment_id` to skip the HTML pre-fetch.

ZH — 抓取任意公众号文章的公开互动数据:阅读数、点赞数、分享数、收藏数、评论数、星标数。两种引擎:`default` 返回全量指标;`h5` 是快速路径,只返回评论数 + 精选评论数,可通过预知 `comment_id` 跳过 HTML 预抓(节省约一半延迟)。

***

### 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) |
| **Pull interaction metrics for a given article URL (this Actor)** | — |
| Read the account's profile (IP region, original count, ban status) | [WeChat Account Profile Scraper](https://console.apify.com/actors/3JV499ECEjb5un854) |
| Read all comments + replies on an article | [WeChat Article Comments Scraper](https://console.apify.com/actors/comments) |
| 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. Both short (`/s/<sn>`) and long (`/s?__biz=...&mid=...`) forms accepted. |
| `engine` | string | `"default"` | `default` = full metrics via `/fetch_article_stats`. `h5` = `/fetch_article_stats_h5` fast path; returns only `comment_count` + `elected_comment_count`. |
| `commentId` | string | `""` | Pre-known comment\_id from `/fetch_article_detail` response's `commentId` field. Only used when `engine=h5`; speeds up the upstream call by skipping the HTML pre-fetch. Leave empty to let upstream fetch the article HTML itself. |
| `raw` | string | `"false"` | `false` = omit raw upstream payload; `true` = attach `rawData` for debugging. |

#### Where to get a URL

- From a friend's share: copy the URL directly.
- From the [Article Detail Scraper](https://console.apify.com/actors/5vrr8dBcnclIva0Lx): pass any URL you have, get back `commentId` + body.
- From the [Account Articles Scraper](https://console.apify.com/actors/vxAjW6anQJQWk7xTF): each row's `url` field is an article URL.

***

### Output (one row per Actor run)

#### `engine=default`

```json
{
  "url": "https://mp.weixin.qq.com/s/TSNQKkRpN1qbKsT7BvzqIw",
  "engine": "default",
  "readNum": 19839,
  "likeCount": 74,
  "oldLikeCount": 123,
  "shareCount": 693,
  "collectCount": 108,
  "starNum": 46,
  "commentCount": 3,
  "electedCommentCount": null,
  "unavailable": [],
  "collectedAt": "2026-09-16T12:00:00.000Z"
}
```

#### `engine=h5`

```json
{
  "url": "https://mp.weixin.qq.com/s/...",
  "engine": "h5",
  "readNum": null,
  "likeCount": null,
  "oldLikeCount": null,
  "shareCount": null,
  "collectCount": null,
  "starNum": null,
  "commentCount": 4,
  "electedCommentCount": 2,
  "unavailable": ["read_num", "like_count", "old_like_count", "share_count", "collect_count", "star_num"],
  "collectedAt": "2026-09-16T12:00:00.000Z"
}
```

**Field notes**

- For `engine=h5`, fields the H5 page doesn't expose come back as `null` (not zero). The `unavailable` array lists the names the upstream explicitly marked unavailable.
- `oldLikeCount` is the legacy "likes" count tracked separately from the modern in-article likes.
- `starNum` is "star" (星标) — users who favorited the official account from this article.
- `electedCommentCount` is the count of comments hand-picked by the publisher (精选评论).

***

### 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/<ACTOR_ID>/runs?waitForFinish=60" \
     -H "Authorization: Bearer <APIFY_TOKEN>" \
     -H "Content-Type: application/json" \
     -d '{"url":"https://mp.weixin.qq.com/s/...", "engine":"default"}'
   ```
3. **CLI**:
   ```bash
   apify call wechat-article-metrics-scraper \
     -i '{"url":"https://mp.weixin.qq.com/s/...", "engine":"h5", "commentId":"12345"}'
   ```

Free users: 5 runs/day. Paid users: 1 PPE event per run (`article-metrics-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 (you are here)** | **Article Metrics Scraper** | **…/actor** |
| step ④ comments | Article Comments Scraper | …/comments |
| step ① profile (alt) | [Account Profile Scraper](https://console.apify.com/actors/3JV499ECEjb5un854) | …/3JV499ECEjb5un854 |

**You are here:** **Article Metrics Scraper** (step ③) — pair it with a Detail Scraper output to get the body's `commentId` and pass it here as `commentId` for fast-path `engine=h5`.

***

### Pricing

1 PPE event per Actor run (`article-metrics-result`). Engine choice doesn't affect pricing — both call the upstream once.

***

### Tests

```bash
npm test
```

Runs unit assertions (input validation, body shape, normalize across `default` / `h5` / `raw=true` / `raw=false`, null handling) plus 9 integration scenarios (mock fetch drives the full `run()` flow including default/h5 engines, commentId forwarding, 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-metrics-scraper/changelog.md

# Actor input Schema

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

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

## `engine` (type: `string`):

default = full metrics via /fetch\_article\_stats (recommended). h5 = /fetch\_article\_stats\_h5 fast path — returns comment\_count + elected\_comment\_count; pass comment\_id below to skip the HTML pre-fetch (saves ~50% latency).

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

Optional. Pre-known comment\_id from /fetch\_article\_detail (the response's commentId field). Only honored when engine=h5; speeds up the upstream call by skipping the HTML pre-fetch. Leave empty to let upstream fetch the article HTML itself.

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

Attach the unprocessed upstream data object as rawData. Default false keeps datasets small.

## Actor input object example

```json
{
  "url": "https://mp.weixin.qq.com/s/TSNQKkRpN1qbKsT7BvzqIw",
  "engine": "default",
  "commentId": "",
  "raw": "false"
}
```

# Actor output Schema

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

Each pushed item contains parsed interaction metrics for one article URL.

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

Article URL, engine, read/like/comment counts, 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-metrics-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-metrics-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-metrics-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-metrics-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/y3ZqhBdIY2LzGtkVK/builds/Q2auf0rovOt0w3IFk/openapi.json
