← 返回
未分类

Dcard

擷取 Dcard 文章完整內文。Dcard 有 Cloudflare 保護,需用 patchright (Playwright) headless browser 繞過。支援文章標題、全文、圖片連結輸出。
使用 patchright (Playwright) headless browser 绕过 Cloudflare,获取 Dcard 文章标题、正文和图片链接。
ichendong
未分类 clawhub v0.1.1 1 版本 99545.5 Key: 无需
★ 0
Stars
📥 219
下载
💾 0
安装
1
版本
#dcard#forum#latest#scraping#taiwan

概述

Dcard 🎴

用 Camoufox(Firefox-based stealth browser)+ patchright 繞過 Dcard 的 Cloudflare 保護。

Camoufox 內建 uBlock Origin + 反指紋偵測,可以直接 bypass Cloudflare challenge,

且 Firefox 不會有 WSL2 + Tailscale DNS 的問題。

使用方式

# 單篇文章
dcard_fetch.py https://www.dcard.tw/f/relationship/p/261529038

# 純 ID(預設看板 relationship)
dcard_fetch.py --id 261529038

# 指定看板
dcard_fetch.py --forum makeup --id 123456

# JSON 輸出
dcard_fetch.py https://www.dcard.tw/f/relationship/p/261529038 --format json

# 看板熱門
dcard_fetch.py list relationship

# 看板最新
dcard_fetch.py list relationship --sort latest --limit 10

# 全站熱門看板
dcard_fetch.py list --all-forums

腳本

  • scripts/dcard_fetch.py — 主腳本(Python3.14)
  • scripts/_list_posts.js — 看板列表用 JS extractor

安裝依賴

需要 Camoufox + patchright + lxml

# 1. 安裝 Camoufox + patchright + lxml
pip3.14 install camoufox lxml patchright

# 2. 下載 Camoufox 瀏覽器(~280MB)
camoufox fetch

# 檢查
camoufox version
# → Camoufox: v135.0.1-beta.xx (Up to date!)

技術細節

為什麼用 Camoufox 而不是 Chromium?

  • Firefox 在 WSL2 下 DNS 正常(Tailscale DNS 不會炸)
  • 內建 uBlock Origin 擋廣告與 tracker
  • 自訂指紋不會被 Cloudflare 標記為 headless
  • 不需要 --host-resolver-rules 繞 DNS

JSON-LD 解析: 內文從