技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
scraping-html-to-markdown【数据与研究】Use when the user wants a single page rendered as clean Markdown plus structured metadata. Covers `crawlberg scrape URL`, JSON vs Markdown output, what metadata is returned, and how to handle JS-heavy pages.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
crawlberg scrape URL, JSON vs Markdown
output, what metadata is returned, and how to handle JS-heavy pages.crawlberg scrape <url> is the right tool when the user has a single
page in mind. It returns Markdown plus a full structured payload (metadata,
links, images, JSON-LD, HTTP response info).
crawlberg scrape https://example.com/article --format markdown
JSON form (default) when downstream needs metadata:
crawlberg scrape https://example.com/article --format json
| Flag | Default | Purpose |
|---|---|---|
--format | json | json or markdown. |
--timeout | 30000 | Per-request timeout in ms. |
--proxy | — | HTTP, HTTPS, or SOCKS5 proxy URL. |
--user-agent | — | Override request UA. |
--respect-robots-txt | off | Honour robots.txt. |
--browser-mode | auto | auto, always, never — see headless-fallback skill. |
--browser-endpoint | — | External CDP ws:// URL. |
--config | — | Inline JSON or @file.json for full CrawlConfig. |
Prints the rendered Markdown only. Use when piping to a file the user will read, or when the result becomes LLM context downstream.
Top-level PageResult with:
url, final_url (after redirects), status_code.markdown: { content, fit_content, warnings } — fit_content is a
pruned LLM-optimised variant.metadata: Open Graph, Twitter Card, Dublin Core, article tags, JSON-LD,
headings (H1–H6), feeds, favicons, hreflang.links: arrays for Internal, External, Anchor, and Document.images: <img>, <picture>, srcset, og:image.tables: structured table data preserved separately from Markdown.response: HTTP headers, content type, charset, body size.Read result.markdown.content for the Markdown string when scripting.
Static fetch returned a JS shell. Symptoms in JSON output:
markdown.content is short or only contains nav/footer chrome.markdown.warnings mentions JS-render-required.metadata.headings is empty when the page clearly has headings.Re-run with --browser-mode always and see the headless-fallback skill.
Auto mode detects 8 WAF vendors and retries through headless Chrome
automatically. If you forced --browser-mode never, the WAF response will
fall through. Check response.status_code — 403/406/503 with WAF headers
(server: cloudflare, x-amz-cf-id, etc.) is the giveaway.
If --respect-robots-txt is set and the path is disallowed, the scrape
returns an error rather than partial content. Drop the flag only on hosts
you own or have authorisation for.
Most pages declare UTF-8. Pages that lie about their charset can surface as
mojibake in markdown.content. crawlberg exposes no encoding-override option
(there is no force_encoding/charset field in CrawlConfig, and --config
rejects unknown keys), so an incorrectly declared charset is a server-side defect —
re-fetch the raw bytes and transcode them downstream if you hit it.
crawlberg scrape https://blog.example.com/post-123 --format markdown \
> /tmp/article.md
crawlberg scrape https://example.com \
--proxy http://proxy.internal:3128 \
--user-agent "crawlberg (research@example.com)" \
--format json
crawlberg scrape https://example.com --format json \
| jq '.metadata | {title: .og.title, description: .og.description, image: .og.image}'
crawling-a-site skill.crawlberg interact with the action list.crawlberg map.