知乎回答與留言 API

依 2026-11-21 規格整理

快速解答

POST /zhihu/pushs/task 接受知乎問題、回答或專欄文章網址。以問題建立的任務,data 只有回答(push_type 為 answer,每頁 20 則);回答或文章會蒐集第一層留言(comment,每頁 10 則),crawl_second_layer(預設 true)時一併蒐集底下的回覆(reply)。以 GET /zhihu/pushs/task/{task_id} 輪詢,DONE 時回傳 task、total_count 與 data,每頁最多 1000 筆。每筆資料有 post_id、作者、內容、發布時間、情緒標籤,以及已知時的 IP 所在地。資料以網路爬蟲蒐集知乎公開發布的內容。

常見用途

  • 蒐集與自家產品類別或市場相關問題的所有回答。
  • 完整讀取一則有影響力的回答或專欄文章底下的留言串。
  • 比較同一個問題在不同時期的回答情緒。

端點一覽

Base URL 為 https://api.infominer.io/api/v2,每個請求以 auth-header 標頭帶 API 金鑰。

方法路徑說明
POST /zhihu/pushs/task 以問題、回答或專欄文章網址建立任務:問題蒐集回答,回答與文章蒐集留言。
GET /zhihu/pushs/task/{task_id} 輪詢任務;DONE 時回傳回答或留言,每頁最多 1000 筆。

請求參數

POST /zhihu/pushs/task

參數位置型別必填預設值/可用值說明
post_url body string 是 知乎問題網址 https://www.zhihu.com/question/{id}、回答網址 .../question/{id}/answer/{id},或專欄文章網址 https://zhuanlan.zhihu.com/p/{id};查詢字串會被移除。
crawl_second_layer body boolean 否 true 第二層:回答或文章為每則留言底下的回覆。問題會蒐集每則回答的第一頁留言,但這些留言屬於該回答,不在問題任務的 data 裡。
max_pages body integer 否 20(最多 200) 第一層最多爬取的頁數(問題為回答,每頁 20 則;回答或文章為第一層留言,每頁 10 則);0 或省略時用預設值。
rerun body boolean 否 為了與其他平台一致而接受此參數;每次 POST 都會建立新任務。

GET /zhihu/pushs/task/{task_id}

參數位置型別必填預設值/可用值說明
task_id path string 是 建立任務時回傳的任務 ID。
page query integer 否 1 頁碼,從 1 開始。
pageSize query integer 否 1000 每頁回答或留言數,最多 1000。

回應欄位

資料欄位端點
回答、留言與回覆(data) id, post_id, author_id, author, push_type, region, content, tm, tm_crawler, sentiment GET /zhihu/pushs/task/{task_id}
任務(task) task: id, post_url, status, crawl_second_layer, created_at, total, completed, pages_crawled, reported_total, partial, timed_out, failed_pages, failed_batches, zhihu_type, title GET /zhihu/pushs/task/{task_id}

程式碼範例

curl:建立任務

curl -X POST https://api.infominer.io/api/v2/zhihu/pushs/task \
  -H "auth-header: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"post_url": "https://www.zhihu.com/question/100000001/answer/100000000001", "crawl_second_layer": true, "max_pages": 2}'

curl:以任務 ID 輪詢

curl "https://api.infominer.io/api/v2/zhihu/pushs/task/$TASK_ID?page=1&pageSize=1000" \
  -H "auth-header: YOUR_API_KEY"

Python(requests):建立、輪詢、讀取

import time
import requests

BASE_URL = "https://api.infominer.io/api/v2"
HEADERS = {"auth-header": "YOUR_API_KEY"}

# 1. Create the task
resp = requests.post(
    f"{BASE_URL}/zhihu/pushs/task",
    headers=HEADERS,
    json={
        "post_url": "https://www.zhihu.com/question/100000001/answer/100000000001",
        "crawl_second_layer": True,
        "max_pages": 2,
    },
    timeout=30,
)
resp.raise_for_status()
task = resp.json()

# 2. Poll until the task leaves INIT / RUNNING
for _ in range(120):
    resp = requests.get(
        f"{BASE_URL}/zhihu/pushs/task/{task['id']}",
        headers=HEADERS,
        params={
            "page": 1,
            "pageSize": 1000,
        },
        timeout=30,
    )
    resp.raise_for_status()
    result = resp.json()
    status = result.get("status") or result.get("task", {}).get("status")
    if status not in ("INIT", "RUNNING"):
        break
    time.sleep(15)
else:
    raise SystemExit("task still running; poll it again later")

task = result.get("task", result)
if status != "DONE" or task.get("partial") or task.get("timed_out"):
    raise SystemExit(f"task ended with status {status}; no complete result")

# 3. Read the records (use page / pageSize to fetch further pages)
for row in result.get("data", []):
    print(row.get("push_type"), row.get("author"), (row.get("content") or "")[:60])

示意回應樣本

以下為人工撰寫的示意資料:帳號為 sample_user_n,ID 明顯為假值。欄位依 2026-11-21 規格,範例只列出部分欄位。

任務 DONE 後的輪詢回應(示意資料)

{
  "task": {
    "id": "00000000-0000-4000-8000-000000000001",
    "post_url": "https://www.zhihu.com/question/100000001/answer/100000000001",
    "status": "DONE",
    "crawl_second_layer": true,
    "created_at": 1780880400,
    "total": 2,
    "completed": 2,
    "pages_crawled": 1,
    "reported_total": 2,
    "timed_out": false,
    "partial": false,
    "failed_pages": 0,
    "failed_batches": 0,
    "zhihu_type": "answer",
    "title": "空气炸锅值得买吗?"
  },
  "total_count": 2,
  "data": [
    {
      "id": "00000000-0000-4000-8000-000000000003",
      "post_id": "00000000-0000-4000-8000-000000000001",
      "author_id": "0000000003",
      "author": "sample_user_3",
      "tm": 1780745400,
      "tm_crawler": 1780880403,
      "push_type": "comment",
      "region": "浙江",
      "content": "同感,容量确实是最大的问题",
      "sentiment": "Neutral"
    },
    {
      "id": "00000000-0000-4000-8000-000000000004",
      "post_id": "00000000-0000-4000-8000-000000000001",
      "author_id": "0000000004",
      "author": "sample_user_4",
      "tm": 1780743600,
      "tm_crawler": 1780880406,
      "push_type": "reply",
      "region": "江苏",
      "content": "可以考虑大一号的,做两人份刚好",
      "sentiment": "Positive"
    }
  ],
  "page": 1,
  "pageSize": 1000
}

限制與注意事項

  • 以問題建立的任務,data 只有回答;回答底下的留言屬於該回答,要完整留言請以回答網址建立任務。
  • crawl_second_layer 為 true 時,以問題建立的任務也會蒐集每則回答的第一頁留言(最多 10 則),這些留言屬於該回答,要以回答網址建立任務讀取。
  • 知乎每頁固定 10 則第一層留言,無法調整。
  • 知乎任務能同時執行的數量有限,短時間大量請求也可能讓知乎暫時限制存取,請分散建立任務。
  • 只有 DONE 的輪詢回應帶資料,PARTIAL、TIMED_OUT 與 FAILED 只回傳任務物件。status 為 DONE 且 partial、timed_out 都是 false,才算完全成功。
  • data 包含這則內容所有已蒐集的回答或留言(含先前任務蒐集的),所以 total_count 與 task.completed 不一定相同。數值是蒐集當下的值。
蒐集方式:以網路爬蟲蒐集各平台公開發布的內容。是否適用於您的用途,依用途與法域由買方法務評估,我們可提供來源與蒐集方式說明。

更多 知乎 API 頁面

申請試用

填寫下方申請表單時,請註明知乎,並說明要追的關鍵字或問題、是否需要回答與留言,以及預估資料量。我們會確認範圍,並回覆試用與 API 金鑰的安排。

填寫表單申請試用,專人確認範圍後回覆試用與介接安排。

填寫申請表單

常見問題

怎麼拿到知乎回答底下的留言?
以回答網址 https://www.zhihu.com/question/{問題 ID}/answer/{回答 ID} 建立任務。以問題網址建立的任務,data 只有回答。
zhihu_type 代表什麼?
建立任務所用網址的類型:question、answer 或 article,決定第一層是回答還是留言。
知乎回答任務要跑多久?
約 5 到 10 秒準備後,一則回答的兩頁留言約 20 秒,一個問題的一頁回答約 1 分鐘;超過同時執行上限的任務會先以 INIT 排隊。
資料是怎麼蒐集的?這是知乎官方的 API 嗎?
資料以網路爬蟲蒐集知乎公開發布的內容。LargitData 與知乎沒有隸屬或合作關係,這也不是知乎自身提供的 API。是否適用於您的用途,依用途與法域由買方法務評估,我們可提供來源與蒐集方式說明。