Feishu doc scraper

From daymade/claude-code-skills · View interactive version

Feishu doc scraper is an AI agent skill from the GitHub repository daymade/claude-code-skills. Extracts Feishu/Lark Docs, Wiki, Sheets, and Minutes (妙记) transcripts into faithful local Markdown via the lark-cli API — no LLM paraphrasing, browser-DOM fallback when lark-cli can't reach content. Use whenever the source is a Feishu/Lark URL and fidelity matters — 导出飞书文档/合集/妙记转写, 把飞书 wiki 转 markdo

How to use this skill

Skill file

Feishu Doc Scraper

Extract a Feishu/Lark source into faithful local Markdown. Prefer the lark-cli API — it extracts the body programmatically (no model paraphrasing), follows a collection's reference graph, and reads permission boundaries from error codes instead of guessing. Treat the rendered browser page as a fallback, not the source of truth: in real collection-scraping work the API path consistently does the whole job while the browser path is never needed.

Scope (read this first)

This skill's contract is faithful per-source Markdown + a record of what was extracted. Naming, indexing, deduplication and knowledge ownership belong to the recipient's archive workflow. For a filing request, including permission to choose a suitable location, first follow archive destination handoff. Temporary extraction may proceed while the destination is unresolved; permanent filing and uploads follow the host's selected ownership and storage contract.

For every document read or archived, load comments and feedback.

It owns the body-plus-discussion workflow, selected scope, body-only exception,

snapshot commands, interpretation and coverage checks.

Extraction and durable storage are separate decisions. A downloaded MP4/XLSX/DOCX/image is a working copy, not evidence that the file belongs in Git or Git LFS. For a knowledge-base archive, default to:

Before filing an archive, declare this split in an artifact manifest and run the bundled storage validator. The complete schema and examples are in references/archive-storage-contract.md.

Keep source access instructions with the authorized destination's material entry,

following the destination handoff; return them with a password-protected source

link. Generate aggregate statistics on demand under the storage contract.

Select the delivery scope from the user's requested result before loading fallback

or reader procedures. For original-file downloads, use

attachment archives: fetch the body first,

enumerate its actual resource types, then load only those handlers. Record body,

attachments, independent retention and reader acceptance separately. An attachment

batch alone never establishes completion of the document's reference graph.

For website links, Bilibili, YouTube or direct-media links in the body, load

external video discovery and handoff.

Enumerate clickable and plain-text URLs on every captured body; opaque websites

remain link locators until selected for inspection. Use the reference's batch

scope/volume preflight before mass acquisition or cloud creation. Discovery,

text capture and media acquisition have separate completion states. Delegate

authorized acquisition to the installed platform/storage owner with the user's

selected part or playlist range.

For failed media exports, original-preview retrieval, or an Obsidian reading handoff, load

original media and reader handoff.

Use its verified-preview downloader and API-capture renderer before expanding

the batch. Its Delivery completion gate (check_reader_delivery.py finalize)

is the reader-delivery completion entry; conversion, byte and search success do

not replace a current actual-reader evidence record.

For a user-selected personal favorites destination, its source catalog producer

hands off to favorites-search without changing this Skill's filing ownership.

Choose the path

Before the first linked-resource read, load lark-cli-router and follow its

source account binding.

Retain the selected profile and identity for every branch below.

What is the source?
├── Minutes / 妙记 URL, or a document references one → PATH C: Minutes transcript
├── Owner-exported .docx → PATH B: faithful Markdown
└── Other Feishu/Lark URL (wiki / docx / sheets / base)
    ├── CLI available and source account bound → PATH A: API extraction
    │   └── Body-read permission refused → PATH B: owner-exported .docx
    └── CLI/auth prerequisite missing → use lark-cli-router's preparation route;
        if unavailable, use PATH D only with an authorized browser session

Resolve wiki nodes before choosing a handler. Use the actual obj_type and its installed CLI guide; for example, bitable uses lark-base. A 3380002 Unsupported document type response from docs +fetch identifies a handler mismatch, not a permission denial. If the required guide is unavailable, retain the token and type in the worklist as unextracted.

For Wiki Base/Sheets with a bound account, use table capture

and scripts/capture_table.py for faithful exports, readable records and attachment

provenance. It normalizes Wiki locators, preserves structured CLI errors from both

streams, and keeps unsupported fields, truncation or missing attachments partial.

A collection/hub is just a docx whose body references other docs — Path A handles it by recursively following the reference graph, not by visiting pages in a browser.

Path A — lark-cli API extraction (primary)

Full command catalog, recursion engine, cross-tenant and personal-space nuances: references/lark-cli-api-extraction.md. The essentials for the common case:

Resolve current CLI commands, identity and permission handling through

lark-cli-router when available, otherwise the installed lark-cli skills list

and its selected lark-* guides. Historical examples below document capture

shapes; use the installed guide when flags, response envelopes or methods differ.

For source-card files, the batch archive procedure

uses the exercised download command. A supplied share password does not establish

whether the current identity needs browser access; attempt the authorized API read

first, and respect its permission result.

1. Disable the proxy for Feishu domestic domains. Feishu's *.feishu.cn endpoints are direct-connect in mainland China; routing them through a local proxy leaks credentials through the proxy and gets DNS-hijacked. lark-cli itself warns about this. Always:

export LARK_CLI_NO_PROXY=1

This does not conflict with any "Claude/Anthropic domains must use the proxy" rule — Feishu is a different host and is direct.

2. Classify the URL, then resolve to a fetchable doc token.

```bash

lark-cli wiki spaces get_node --params '{"token":"<node_token>"}'

# → .data.node.obj_token and .data.node.obj_type (e.g. "docx")

```

Then dispatch on the actual obj_type — never assume docx: docx → step 3 below; sheet/sheets → step 4 in the reference; bitable → the installed lark-base guide; file/slides → the installed lark-drive/slides guide. docs +fetch on a non-docx obj_type fails with 3380002 Unsupported document type '…'. Only docx is supported. — that error is evidence the wrong handler was selected, not that the source is unreadable.

3. Fetch the body programmatically — never via the model. Use the

body capture procedure,

which owns the executable recipe, output naming, body-field selection and failure

handling. The source.html / source.md names below refer to that document's own

saved files, not shared filenames for the collection.

⚠️ On this pandoc branch, pandoc -f html -t gfm silently strips several of Feishu's custom embedded tags — verified against real documents, 2026-08-16/17, and the damage is worse the deeper you look:

Because the loss is real and type-dependent, extraction (step 4) and the residual-tag check (step 5) must operate on source.html, never on source.md, whenever this pandoc branch was taken. If the actual response provides .data.markdown, check that saved Markdown instead. Select the branch from the current response, not a remembered CLI version; the 1.0.80 HTML tests establish the pandoc loss mechanism, not which field every later release returns.

--format markdown is not a valid value (lark-cli warns and falls back to json). Keep stdout and stderr separate — a harmless [deprecated] line goes to stderr, and piping 2>/dev/null and jq together produced a false Exit code 5 in practice. The body must reach disk via jq/pandoc, never retyped or summarized by the model — paraphrasing silently corrupts source text, the single most important fidelity rule. (pandoc only re-renders HTML structure to Markdown; it does not rewrite prose — the tag-stripping above is a structural loss, not a prose-fidelity one, which is why source.html must stay on disk and stay authoritative for rich-media references.)

4. If it's a collection/hub, follow the reference graph (BFS) within the user's authorized capture scope. The hub body contains <mention-doc> (real raw tag: <cite doc-id="…">), <sheet>, <image> (real raw tag: <img src="…">) tags, <whiteboard token="…"> blocks, cross-tenant / Minutes / Tencent-Meeting URLs and external video links. Extract every reference, dispatch by type, fetch, and repeat on each newly fetched doc until no new references remain (leaf nodes) — except whiteboard, which is never fetched or recursed: it's inline visual content, not a link to another document (see the dedicated instruction below). External videos enter the resource worklist and owner handoff, not Feishu recursion. The caller applies the user's selected roots, depth and resource set: a reference beyond that scope stays a recorded locator (URL/token + title), marked not-captured in the worklist, and does not become a required fetch. A full-collection request still uses BFS until all in-scope branches reach leaves. Use the bundled extractor so nothing is silently missed (a missed reference = a missing document, the #1 hub-scraping failure):

python3 scripts/feishu_extract_refs.py "<sanitized-title>.html"   # → JSON list of {type, ref, title, dispatch}

Run this once per fetched document — the root, then every newly-fetched child — using that document's own <sanitized-title>.html (see step 3's naming caveat). The extractor scans reference text and parses source-card tags — it works on either the .html or .md for a given document, since it just checks whether the file's text contains the tags — but .html is the one to trust when both exist; fall back to .md only if no .html was ever saved for that document (the .data.markdown branch, see step 3). Recursion loop, dispatch table, and the cross-tenant/my.feishu.cn personal-space rules are in the reference.

Whiteboard blocks are not a followable reference — export and read them in place. A whiteboard token="…" tag is Feishu's native diagram/flowchart block, inlined in the current document — it is not a pointer to another document, so don't try to recurse/fetch it like mention-doc/sheet. It must be understood visually: a flowchart's meaning is not reliably recoverable from raw node coordinates/text-fragment lists alone. Export a preview image and actually look at it:

lark-cli whiteboard +export --whiteboard-token <token> --output-type preview --output <path>.jpg --overwrite

Then use the Read tool on the resulting .jpg to see the diagram's actual content. --output-type raw is also available (structured node JSON — useful as a cross-check/searchable index, but not a substitute for looking at the rendered image); svg and source output types also exist. The output path must have a real image extension matching what the command actually produces (it errors if you ask for .png when the true format is .jpg — match the extension to what the command reports, or omit the extension per its own --help). The preview is a working cache by default: record the whiteboard token, observed MIME/bytes/hash, and optional cache path in the artifact manifest; do not silently promote the JPEG to Git/LFS. If the durable archive needs an independent binary copy, route it explicitly to OSS. This matters because diagrams frequently carry decision-relevant content absent from the document's plain-text sections — e.g. a swimlane/process diagram can carry role-by-role steps and concrete numeric thresholds nowhere else in the doc. Treating a document as "fully extracted" without opening these blocks silently discards exactly the content most likely to carry its actual operating logic.

5. Final residual-tag check (acceptance gate — run this on every fetched document, not just collections). A single standalone document with no cross-doc references still needs this: an inline whiteboard or unresolved reference tag can appear with zero other documents involved (this is exactly what happened on a real single-doc extraction 2026-08-16 — no hub, no recursion, just 3 unread whiteboards). Every rich-media reference must have been resolved and rendered. Run this recursively over the whole working directory, not a single file — a collection has one <sanitized-title>.html/.md pair per document (step 3), and the pandoc-converted .md can report "clean" on its own while real tags were silently dropped (see step 3's callout), so the scan needs to reach every .html on disk:

grep -rlE '<(source|file|lark-table|lark-tr|sheet token=|mention-doc|cite doc-id=|whiteboard token=|view type=)' . \
  && echo "UNRESOLVED — keep recursing" || echo "clean"

lark-tr and view type= in that pattern are pre-existing, unverified-against-real-HTML terms. They have no backing regex in feishu_extract_refs.py and no dispatch entry, so a hit here has no structured tooling support; treat it as "stop and inspect the raw tag by hand," not as something the extractor already understands.

Reconcile every <source>/<file> hit with an attachment token and verified local

file when originals were requested. The extractor preserves source-card filename,

size and MIME; a missing token is unresolved-attachment, never a leaf. Do not

equate a zero-reference result with completeness before checking raw capture tags.

⚠️ On each document's saved .html, "empty" is not a literal stop condition — treat each hit as a worklist item, not a failure to loop on. Each <sanitized-title>.html is an immutable raw capture of that document (nothing in this skill rewrites a document's own file in place once fetched — see step 3's per-document naming caveat), so a parent doc that genuinely references N other docs or M diagrams keeps showing N+M matches forever in its own file, even after every one of them has been correctly handled — chasing this grep to a literal zero across the whole directory will never terminate for a real hub doc. Instead, for every match, verify the corresponding artifact exists on disk: a mention-doc/cite doc-id=/sheet hit is resolved once the referenced child doc has actually been fetched and saved (step 3, applied to that child); a whiteboard hit is resolved once its preview .jpg was exported and Read (step 4) — never by fetching another document, it is not a followable reference. Stop only once every match maps to a verified on-disk artifact. (On the .data.markdown fallback branch, where the fetched body is the deliverable Markdown itself rather than an immutable raw capture, a literal empty result remains the simpler signal — but that branch was not confirmed reachable on any current lark-cli build, see step 3.)

Path B — permission denied → owner-exported .docx

After source account binding, code 131006 … node permission denied, user needs read permission from wiki spaces get_node or docs +fetch is a Feishu-side body-read boundary for that identity. Do not retry it through curl, another transport or an unbound account. Ask the permission holder for an owner-exported .docx, then convert with fidelity. Full procedure: references/docx-export-to-markdown.md. Minutes scope and per-minute errors follow Path C instead.

Path C — Feishu Minutes (妙记) transcript

Read the current lark-cli-router and its version-matched lark-meeting guide;

minutes +detail --transcript exports the native text transcript, including

speaker labels and timestamps. Bind the source's already-authorized profile

before the first read and retain its explicit --profile and --as throughout.

Read each requested minute's result and returned transcript path; batch process

success alone does not prove every transcript was exported. Do not start a new

login/scope grant merely because the active organization cannot read the source.

Follow the domain's actual permission result without browser/raw-API workarounds.

Keep the native transcript rather than downloading media to re-run ASR.

Export paths, raw-endpoint format variants and scope-error handling are in

references/feishu-minutes-transcript.md;

use the installed guide when its command contract differs from historical examples.

Path D — browser DOM fallback (last resort)

Only when lark-cli genuinely cannot reach the content (no install possible, and the doc is not permission-walled). This is the old virtual-scroll / TOC-driven DOM capture workflow. It is slower, depends on a connected browser surface (the in-browser extension frequently fails to connect), and an anonymous debugging Chrome can only tell you whether a page is publicly reachable — it cannot read login-walled content. Workflow: references/browser-dom-fallback.md. Battle-tested DOM rules (virtual scroll, data-block-id ordering, table/bullet extraction, image streams): references/browser-failure-rules.md.

Hard rules

These are the rules whose violation silently ruins the output. Each has a reason — follow the reason, not just the letter.

rich-media extraction and leaf gate.

It defines the source representation to check; the body-capture procedure owns

per-document filenames and existing-output refusal.

Acceptance contract

Stop only when all that apply are true:

Do NOT attempt

Verified dead-ends — retrying them only wastes the session. Full table with failure modes and root causes: references/permission-and-failure-boundaries.md. The top ones:

Bundled resources

Next step

Use the destination already selected by the user. For personal favorites, follow

the source-catalog handoff

to favorites-search. Do not reopen that choice as a PKM recommendation or promote

private material to a team collection. When the user authorizes choosing a

suitable archive, complete the destination handoff

through the host's conventions. For extraction-only requests without filing

authorization, deliver the faithful capture and explicit gaps without selecting

a permanent knowledge base.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.