微博留言 API

依 2026-10-25 規格快照

快速解答

以貼文網址呼叫 POST /weibo/pushs/task,會建立非同步任務,蒐集該則貼文的留言。order_type 可選 hot、time 或 both;crawl_second_layer=true 時一併蒐集第二層回覆;get_all=true 時關閉重複檢查,蒐集全部留言。以 GET /weibo/pushs/task/{task_id} 輪詢;DONE 時回傳留言與 total_count,每頁最多 1000 筆。每則留言以 post_id 指回所屬貼文,並帶有作者、內文、情感標籤與時間戳記。資料以網路爬蟲蒐集微博公開發布的內容。

常見用途

  • 了解讀者對品牌公告、產品上市或新聞貼文的反應,而不只是貼文本身的內容。
  • 比較同一主題下多則貼文的留言情感標籤。
  • 搭配轉發 API,區分回覆貼文的人與轉發貼文的人。

端點一覽

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

方法路徑說明
POST /weibo/pushs/task 以貼文網址建立留言蒐集任務,可選排序與是否含第二層回覆。
GET /weibo/pushs/task/{task_id} 輪詢留言任務;DONE 時回傳留言,每頁最多 1000 筆。

請求參數

POST /weibo/pushs/task

參數位置型別必填預設值/可用值說明
post_url body string 是 微博貼文網址,例如 https://m.weibo.cn/detail/{id}。
crawl_second_layer body boolean 否 false 一併蒐集第二層回覆。
get_all body boolean 否 false 關閉重複檢查,蒐集全部留言。
order_type body string 否 預設 hot; 可用值 hot | time | both 留言排序方式。

GET /weibo/pushs/task/{task_id}

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

回應欄位

資料欄位端點
留言 id, post_id, author, author_id, content, push_type, sentiment, tm, tm_crawler, region GET /weibo/pushs/task/{task_id}

程式碼範例

curl:建立任務

curl -X POST https://api.infominer.io/api/v2/weibo/pushs/task \
  -H "auth-header: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"post_url": "https://m.weibo.cn/detail/0000000000000001", "order_type": "time", "crawl_second_layer": true}'

curl:以任務 ID 輪詢

curl "https://api.infominer.io/api/v2/weibo/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}/weibo/pushs/task",
    headers=HEADERS,
    json={
        "post_url": "https://m.weibo.cn/detail/0000000000000001",
        "order_type": "time",
        "crawl_second_layer": True,
    },
    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}/weibo/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")

if status == "FAILED":
    raise SystemExit("task failed")
if status != "DONE":
    print("task ended with status", status, "- results may be incomplete")

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

示意回應樣本

以下為人工撰寫的示意資料:帳號為 sample_user_n,ID 為明顯的假值。欄位依 2026-10-25 規格快照;樣本只呈現部分欄位,完整清單見上方表格。

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

{
  "task": {
    "id": "00000000-0000-4000-8000-000000000001",
    "status": "DONE"
  },
  "total_count": 2,
  "data": [
    {
      "id": "0000000000000101",
      "post_id": "0000000000000001",
      "author": "sample_user_3",
      "author_id": "0000000000000003",
      "tm": 1781065800,
      "tm_crawler": 1781150400,
      "content": "这家店的浅焙豆子确实不错,周末想去试试",
      "sentiment": "Positive"
    },
    {
      "id": "0000000000000102",
      "post_id": "0000000000000001",
      "author": "sample_user_4",
      "author_id": "0000000000000004",
      "tm": 1781067600,
      "tm_crawler": 1781150400,
      "content": "请问营业时间到几点?",
      "sentiment": "Neutral"
    }
  ]
}

限制與注意事項

  • 留言每頁最多讀取 1000 筆。
  • crawl_second_layer 預設為 false;需要第二層回覆時設為 true。
  • 留言任務預設會做重複檢查;要蒐集全部留言時,把 get_all 設為 true。
  • 每則貼文的資料量與更新頻率,依專案範圍確認。
蒐集方式:以網路爬蟲蒐集各平台公開發布的內容。是否適用於您的用途,依用途與法域由買方法務評估,我們可提供來源與蒐集方式說明。

更多 微博 API 頁面

申請試用

填寫下方申請表單時,請註明微博,並說明要追的關鍵字(中文或英文訂閱)、是否需要留言、轉發與轉發鏈,以及預估資料量。我們會確認範圍,並回覆試用與 API 金鑰的安排。

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

填寫申請表單

常見問題

怎麼取得微博留言底下的回覆?
建立留言任務時把 crawl_second_layer 設為 true,預設為 false。
post_url 接受哪一種網址格式?
規格中的範例使用行動版貼文網址 https://m.weibo.cn/detail/{id}。
留言如何對應到所屬貼文?
每筆留言紀錄都有 post_id 欄位,指向所屬貼文,因此來自多個任務的留言都能對回各自的貼文。
資料是怎麼蒐集的?這是微博官方的 API 嗎?
資料以網路爬蟲蒐集微博公開發布的內容。LargitData 與微博沒有隸屬或合作關係,這也不是微博自身提供的 API。是否適用於您的用途,依用途與法域由買方法務評估,我們可提供來源與蒐集方式說明。