# 怎麼不登入匯出一個公眾號的全部歷史文章？

> 不掃碼、不用微信 Cookie，匯出公眾號全部歷史文章的標題、連結和全文。用到的三個介面、費用和程式碼。

網頁版：https://okdata.online/zh-hant/answers/export-wechat-official-account-articles/

**簡短回答：**先用公眾號搜尋拿到原始 ID（gh_…），已經知道微訊號的話可以跳過這一步。再用歷史文章介面翻頁，每次 10 篇（每次 $0.02），最後逐篇取全文（每篇 $0.02）。全程不掃碼、不用 Cookie。500 篇文章的號全文匯出共 $11.58，只要標題和連結則是 $1.58。

常見的公眾號匯出辦法都要有人用微信掃碼登入，登入態一過期就失效。用 okdata 只需要一個 API key：不用微訊號，不用 Cookie，不用掃碼。

## 三步呼叫

1. **找到公眾號。** [公眾號搜尋](/zh/apis/wechat_mp/accounts/search/)按名稱搜尋，返回匹配的公眾號，每個結果的 `id` 就是原始 ID，比如 `gh_363b924965e9`。搜尋按返回的帳號數計費，一整頁最多 $0.58，已經知道微訊號就不必搜。
2. **列出歷史文章。** [公眾號歷史文章](/zh/apis/wechat_mp/accounts/articles/list/)傳入 `id`（原始 ID 或微訊號），每次返回 10 篇，從新到舊，帶標題、連結和釋出時間。把 `page.next_cursor` 作為 `cursor` 傳回，直到 `page.has_more` 為 false。
3. **取全文。** [公眾號文章詳情](/zh/apis/wechat_mp/articles/get/)傳入文章連結，返回純文本全文，以及公眾號和釋出時間。詳情裡沒有閱讀數和點贊數，歷史文章列表裡一般也沒有。

## 要花多少錢

| 公眾號規模 | 呼叫次數 | 費用 |
|---|---|---|
| 500 篇，只要標題和連結 | 1 + 50 | $1.58 |
| 500 篇，含全文 | 1 + 50 + 500 | $11.58 |
| 只要最新 20 篇全文 | 1 + 2 + 20 | $1.02 |

已刪除文章返回的 `not_found` 也照常計費；引數錯誤這類還沒請求平台就被攔下的呼叫不扣費。

閱讀和點贊要逐篇另查：[公眾號文章互動資料](/zh/apis/wechat_mp/articles/metrics/)傳文章連結，返回閱讀、點贊、在看、分享、收藏和評論數，每篇 $0.03。500 篇全查要再加 $15.00。只想知道哪些文章表現好的話，只查頭條（`view=full` 時 `ext.position` 為 1），或者只查最近 50 篇（$1.50），一般就夠了。

## 程式碼

```python
import json, os, requests

API = "https://api.okdata.online/v1"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}

def get(path, **params):
    body = requests.get(f"{API}/{path}", headers=H, params=params, timeout=60).json()
    if body["code"] != "ok":
        raise RuntimeError(f"{body['code']}: {body['message']}")
    return body

account = get("wechat_mp/accounts/search", query="36氪")["data"]["items"][0]["id"]

cursor, articles = None, []
while True:
    body = get("wechat_mp/accounts/articles/list", id=account, **({"cursor": cursor} if cursor else {}))
    articles += body["data"]["items"]
    if not body["page"]["has_more"]:
        break
    cursor = body["page"]["next_cursor"]

with open("articles.jsonl", "w", encoding="utf-8") as out:
    for a in articles:
        full = get("wechat_mp/articles/get", url=a["url"])["data"]["item"]
        out.write(json.dumps(full, ensure_ascii=False) + "\n")
```

## 注意事項

- 匯出的記錄裡沒有閱讀和點贊：文章詳情的 `metrics.views` 和 `metrics.likes` 是 null，歷史文章列表裡一般也是，`meta.unavailable` 會註明。這兩個數從互動資料介面取，記下查詢日期：閱讀數會連漲好幾天。
- 新 key 自帶的 $0.20 試用額度不夠做一次搜尋，搜尋會先凍結最多 $0.58。可以直接用已知的微訊號開始，或者先充值。
- 作為長任務跑時，每篇文章帶一個 `Idempotency-Key`，已經成功的那篇重試時不會重複扣費。
- 文章版權屬於作者。匯出用於研究、監測或備份自己的號；轉載時請尊重版權。

## 用到的介面

- [公眾號搜尋](https://okdata.online/zh/apis/wechat_mp/accounts/search/) `wechat_mp.accounts.search`：$0.058/條 · 每次最多 $0.58
- [公眾號歷史文章](https://okdata.online/zh/apis/wechat_mp/accounts/articles/list/) `wechat_mp.accounts.articles.list`：$0.02/次 · 每頁約 10 篇文章
- [公眾號文章詳情](https://okdata.online/zh/apis/wechat_mp/articles/get/) `wechat_mp.articles.get`：$0.02/次
- [公眾號文章互動資料](https://okdata.online/zh/apis/wechat_mp/articles/metrics/) `wechat_mp.articles.metrics`：$0.03/次

## 更多微信公眾號內容

- [微信公眾號 API](https://okdata.online/zh/apis/wechat_mp/)
- [公眾號 API Python 教程：把文章轉成 Markdown 給 RAG 用（2026）](https://okdata.online/zh/guides/wechat-official-account-api-python/)
- [怎麼拿到一個公眾號的歷史文章和全文](https://okdata.online/zh/guides/wechat-official-account-articles/)
- [公眾號文章資料 API 多少錢？](https://okdata.online/zh/answers/wechat-official-account-api-price/)
- [怎麼不登入匯出一個公眾號的全部歷史文章？](https://okdata.online/zh/answers/export-wechat-official-account-articles/)
- [怎麼監控競品公眾號每天發了什麼？](https://okdata.online/zh/answers/monitor-competitor-wechat-official-accounts/)
- [有沒有能讓 AI 讀公眾號文章的 MCP？](https://okdata.online/zh/answers/wechat-official-account-mcp-server/)
- [公眾號次條、第三條以後的文章，閱讀比頭條少多少？（2026 實測）](https://okdata.online/zh/answers/wechat-headline-vs-secondary-article-reads/)
- [為什麼 ChatGPT、Claude 打不開公眾號文章連結？怎麼讓 AI 讀到全文？](https://okdata.online/zh/answers/ai-read-wechat-article-link/)
- [平台官方 API 和第三方資料介面怎麼選（2026）](https://okdata.online/zh/compare/official-apis-vs-data-apis/)
- [社媒資料 MCP 伺服器：自己部署還是用託管的](https://okdata.online/zh/compare/social-media-data-mcp-servers/)
- [公眾號文章和閱讀數介面有哪些？官方介面、第三方 API、開源工具、資料平台 4 類方案怎麼選（2026）](https://okdata.online/zh/compare/wechat-article-data-apis/)
- [獲取微信公眾號資料的幾種辦法：官方介面、RSS 橋接和資料介面](https://okdata.online/zh/compare/wechat-official-account-data-apis/)
- [讓 AI 讀小紅書、抖音、公眾號的 MCP 有哪些？開源自部署、瀏覽器自動化、託管 3 類怎麼選（Claude、Cursor、豆包）](https://okdata.online/zh/compare/xiaohongshu-douyin-wechat-mcp-servers/)

## 資料來源

這個問題出現過的地方（讀取於 2026-11-12）：

- https://github.com/wechat-article/wechat-article-exporter/issues/127
- https://github.com/wechat-article/wechat-article-exporter/issues/154

更新於 2026-11-12
