# WeChat Article Detail Scraper — 公众号文章正文提取 (`opspilot.cc/wechat-article-detail-scraper`) Actor

EN — Extract a WeChat Official Account article by URL: body, title, author, account identity, head image, cover, album info, comment\_id. ZH — 公众号文章详情抓取:正文/作者/账号/头像/封面/合集/评论 id。

- **URL**: https://apify.com/opspilot.cc/wechat-article-detail-scraper.md
- **Developed by:** [wang wei](https://apify.com/opspilot.cc) (community)
- **Stats:** 1 total users, 1 monthly users, 91.4% 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 Detail Scraper — 公众号文章正文提取

> Pass a WeChat Official Account article URL, get the full body, author, account identity, head image, cover, album info, and comment ID. Short links auto-resolve. 64-bit IDs preserved as strings.

### Why Use This Actor

| Problem | How This Actor Solves It |
|---|---|
| You have a WeChat article URL but only need the clean text | Returns HTML-stripped `contentText` ready for downstream NLP / summarization |
| Comments, head image, and account identity are scattered across multiple calls | One Actor call returns title, author, publish time, account nickName + ghUsername + alias, head image (round + HD), cover, album info, and comment\_id |
| WeChat's 64-bit comment\_id loses precision in JavaScript Number | All IDs are string-typed (JSON-safe per upstream convention) |
| You want to scan many articles without logging into WeChat | Single endpoint, no login required |

### What You Get

For each article URL you push one row containing:

- **Identity**: `url`, `bizUin`, `itemIdx`, `msgId`
- **Body**: `title`, `summary`, `author`, `contentText` (full plain-text body, HTML stripped), `contentTextLength`, `contentTextTruncated`
- **Account**: `nickName`, `ghUsername`, `alias`
- **Visuals**: `coverUrl`, `headImage`, `headImageHd`
- **Time**: `publishTimeText` (human-readable), `publishTime` (epoch seconds)
- **Engagement bridge**: `commentId` (feed to WeChat Article Comments Scraper for the comment thread)
- **Album**: `album.{id, title, prevLink, nextLink}` when the article belongs to a collection
- **Provenance**: `sourceEndpoint` (`fetch_article_detail` or `fetch_article_detail_h5`), `collectedAt`
- **Optional**: `rawData` (full upstream payload when `raw=true`)

Plus a run summary (`SUMMARY` KV store record) with title, account, publish time, tier, free-tier counter.

### Quick Start

#### 1. Run with Example Input

```json
{
  "url": "https://mp.weixin.qq.com/s/TSNQKkRpN1qbKsT7BvzqIw"
}
```

Click **Start**. Free users get 5 runs/day; paid users are billed per result (`article-detail-result` event).

#### 2. Export Your Results

Open the **Dataset** tab → CSV / JSON / Excel export.

### Input Reference

#### Top-Level Structure

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

#### `url` — Article URL

- **Required**: yes
- **Type**: string
- **Pattern**: `^https?://.*mp\.weixin\.qq\.com`
- **Description**: WeChat Official Account article link. Short links (`mp.weixin.qq.com/s/<id>`) and long links (with `__biz`) both work. **Exactly 1 per run** (one upstream call = one $0.01 charge).

#### `engine` — Endpoint variant

- **Required**: no (default `default`)
- **Type**: enum `default` / `h5`
- **Description**: `default` returns alias + head image fields (recommended). `h5` is faster but alias and head image are always `null`.

#### `maxContentChars` — Content truncation cap

- **Required**: no (default `0` = no truncation)
- **Type**: integer `0` - `200000`
- **Description**: Truncate `contentText` to this many characters. Set to e.g. `3000` if you only need the lead. `contentTextLength` always reports the original full length.

#### `raw` — Include raw upstream payload

- **Required**: no (default `false`)
- **Type**: enum `false` / `true`
- **Description**: When `true`, the unprocessed upstream `data` object is attached as `rawData` on the pushed item. Useful for debugging or downstream pipelines that need the raw response. Default keeps datasets small.

### Output Reference

#### Article record (one per pushed item)

| Field | Type | Description |
|---|---|---|
| `url` | string | The article URL (input echo) |
| `bizUin` | int | Account's internal numeric ID |
| `itemIdx` | int | Position in the article batch (single-image articles = `1`) |
| `msgId` | string | number | Internal message ID (string when upstream returns a 64-bit value) |
| `sourceEndpoint` | string | `fetch_article_detail` or `fetch_article_detail_h5` |
| `title` | string | Article title |
| `nickName` | string | Account display name |
| `ghUsername` | string | Account `gh_…` ID (feed to WeChat Account Profile Scraper) |
| `alias` | string | null | Account micro-signal ID; `null` when using `engine=h5` |
| `author` | string | Article author byline |
| `summary` | string | Article summary / lede |
| `publishTimeText` | string | Human-readable publish time (e.g. `2025-03-05 12:22`) |
| `publishTime` | int | null | Epoch seconds (UTC+8) |
| `coverUrl` | string | Cover image URL |
| `commentId` | string | 64-bit comment thread ID — feed to the Comments Scraper |
| `headImage` | string | null | Account round head image; `null` when using `engine=h5` |
| `headImageHd` | string | null | Account HD head image; `null` when using `engine=h5` |
| `album` | object | null | `{ id, title, prevLink, nextLink }` for collection-bound articles |
| `contentTextLength` | int | Full original body length (always reported) |
| `contentText` | string | null | Plain-text body (HTML stripped). `null` only if upstream returns nothing. |
| `contentTextTruncated` | boolean | `true` when `maxContentChars` clipped the body |
| `rawData` | object | undefined | Full upstream payload (only when `raw=true`) |
| `collectedAt` | string | ISO 8601 timestamp of when the item was normalized |

#### Run summary (`SUMMARY` KV record)

| Field | Description |
|---|---|
| `url`, `engine` | Input echo |
| `title`, `nickName`, `ghUsername` | Article identity |
| `publishTime`, `contentTextLength`, `contentTextTruncated` | Metadata |
| `commentId`, `msgId` | Bridge IDs for downstream Actors |
| `sourceEndpoint` | Which upstream variant served the data |
| `tier` | `paid` or `free` |
| `freeTierRunsToday` | Free-tier counter (only present when tier=free) |
| `autoFilled` | List of fields defaulted by the runtime (for support diagnostics) |
| `collectedAt` | ISO 8601 timestamp |

### Pricing & Limits

- **Free tier**: 5 runs/day, capped at the Actor's default KV store
- **Paid tier**: $0.01 per article (`article-detail-result` event)
- **Hard caps**: 1 URL per run (cost-control: one upstream request = one $0.01 charge)
- **Upstream latency**: ~30 s on the upstream side; this Actor uses a 60 s client timeout to avoid billing-without-response

### Use it together with the other WeChat Actors

| Where in the pipeline | Actor | Console | Use it to |
|---:|---|---|---|
| before / step ① | [WeChat Article Search Scraper](#) | opspilot.cc/wechat-article-search-scraper | step ① — find article URLs by keyword / business\_type=article |
| sister Actor / step ② | **WeChat Article Detail Scraper** (this one) | opspilot.cc/wechat-article-detail-scraper | sister Actor — extract the full body, author, account, comment\_id |
| after / step ③ | [WeChat Article Comments Scraper](#) | opspilot.cc/wechat-article-comments-scraper | step ③ — feed `commentId` to harvest the full comment thread |
| after / step ③ | [WeChat Article Metrics Scraper](#) | opspilot.cc/wechat-article-metrics-scraper | step ③ — feed `url` to harvest reads / likes / 在看 / shares |
| after / step ④ | [WeChat Account Profile Scraper](#) | opspilot.cc/wechat-account-profile-scraper | step ④ — feed `ghUsername` for account IP region / verification / linked Channels account |

**You are here:** **WeChat Article Detail Scraper** (step ②) — run this on its own for `extract one article's body + identity + comment_id`.

### Support

Open an issue on the [Apify Console run page](https://console.apify.com/actors) for this Actor.

# Changelog

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

# Actor input Schema

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

WeChat Official Account article link. Short links (mp.weixin.qq.com/s/<id>) and long links (with \_\_biz) both work — short links are auto-resolved. Exactly 1 per run.

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

Upstream endpoint variant. `default` returns alias + head image fields (recommended). `h5` is faster but alias/head images are always null.

## `maxContentChars` (type: `integer`):

Truncate the contentText field to this many characters (0 = no truncation). Useful for large articles where you only need the lead. Capped at 200000.

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

Add the unprocessed upstream data object as rawData on the pushed item. Default false keeps datasets small; turn on for debugging or downstream pipelines.

## Actor input object example

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

# Actor output Schema

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

Each pushed item contains one parsed article.

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

Title, account, timestamps, tier, and source endpoint.

# 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-detail-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-detail-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-detail-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-detail-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/5vrr8dBcnclIva0Lx/builds/Wq72hNh167j2ZY6aC/openapi.json
