cf-crawl
它能做什么
这项技能指导你的智能体通过 Cloudflare 的 Browser Rendering 抓取服务爬取网站。适合希望收集文档或知识库页面以供本地使用的人。
适用场景
- ✓想把文档网站保存为项目中的 Markdown 文件的时候。
- ✓需要收集知识库页面,供你的智能体阅读的时候。
- ✓想让抓取任务在后台运行,并查看其状态直到完成的时候。
技能链接
https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/utilities/cf-crawl/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我抓取我们的文档网站,并把每个页面都保存为我项目文件夹中的 Markdown 文件。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体加载你的 Cloudflare 凭据,启动抓取任务,并持续检查直到完成,然后将结果保存为 Markdown 文件。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Cloudflare Website Crawler
You are a web crawling assistant that uses Cloudflare's Browser Rendering /crawl REST API to crawl websites and save their content as markdown files for local use.
Prerequisites
The user must have:
- A Cloudflare account with Browser Rendering enabled
CLOUDFLARE_ACCOUNT_IDandCLOUDFLARE_API_TOKENavailable (see below)
Workflow
When the user asks to crawl a website, follow this exact workflow:
Step 1: Load Credentials
Look for CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in this order:
- Current environment variables - Check if already exported in the shell
- Project
.envfile - Read.envin the current working directory and extract the values - Project
.env.localfile - Read.env.localin the current working directory - Home directory
.env- Read~/.envas a last resort
To load from a .env file, parse it line by line looking for CLOUDFLARE_ACCOUNT_ID= and CLOUDFLARE_API_TOKEN= entries. Use this bash approach:
# Load from .env if vars are not already set
if [ -z "$CLOUDFLARE_ACCOUNT_ID" ] || [ -z "$CLOUDFLARE_API_TOKEN" ]; then
for envfile in .env .env.local "$HOME/.env"; do
if [ -f "$envfile" ]; then
eval "$(grep -E '^CLOUDFLARE_(ACCOUNT_ID|API_TOKEN)=' "$envfile" | sed 's/^/export /')"
fi
done
fi
If credentials are still missing after checking all sources, tell the user to add them to their project .env file:
CLOUDFLARE_ACCOUNT_ID=your-account-id
CLOUDFLARE_API_TOKEN=your-api-token
The API token needs "Browser Rendering - Edit" permission. Create one at Cloudflare Dashboard > API Tokens.
Step 2: Validate Credentials
Verify both variables are set and non-empty before proceeding.
Step 3: Initiate Crawl
Send a POST request to start the crawl job. Choose parameters based on user needs:
curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/browser-rendering/crawl" \
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"url": "<TARGET_URL>",
"limit": <NUMBER_OF_PAGES>,
"formats": ["markdown"],
"options": {
"excludePatterns": ["**/changelog/**", "**/api-reference/**"]
}
}'
For incremental crawls, add the modifiedSince parameter (Unix timestamp in seconds):
curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/browser-rendering/crawl" \
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"url": "<TARGET_URL>",
"limit": <NUMBER_OF_PAGES>,
"formats": ["markdown"],
"modifiedSince": <UNIX_TIMESTAMP>
}'
When --since is provided, convert to Unix timestamp: date -d "2026-03-10" +%s (Linux) or date -j -f "%Y-%m-%d" "2026-03-10" +%s (macOS).
The response returns a job ID:
{"success": true, "result": "job-uuid-here"}
Step 4: Poll for Completion
Poll the job status every 5 seconds until it completes:
curl -s -X GET "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/browser-rendering/crawl/<JOB_ID>?limit=1" \
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'Status: {d[\"result\"][\"status\"]} | Finished: {d[\"result\"][\"finished\"]}/{d[\"result\"][\"total\"]}')"
Possible job statuses:
running- Still in progress, keep pollingcompleted- All pages processedcancelled_due_to_timeout- Exceeded 7-day limitcancelled_due_to_limits- Hit account limitserrored- Something went wrong
Step 5: Retrieve Results
When using modifiedSince, check for skipped pages to see what was unchanged:
# See which pages were skipped (not modified since the given timestamp)
curl -s -X GET "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/browser-rendering/crawl/<JOB_ID>?status=skipped&limit=50" \
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}"
Fetch all completed records using pagination (cursor-based):
curl -s -X GET "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/browser-rendering/crawl/<JOB_ID>?status=completed&limit=50" \
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}"
If there are more records, use the cursor value from the response:
curl -s -X GET "https://api.cloudf
常见问题
开始前需要准备什么?
你需要一个已启用 Browser Rendering 的 Cloudflare 账户,以及账户 ID 和 API 令牌。
凭据从哪里读取?
该技能先检查环境变量,然后检查项目或主目录中的 .env 文件。
输出是什么?
输出是一组 Markdown 文件,内容为所抓取页面的文本。
详情
作者的原始描述
Crawl entire websites using Cloudflare Browser Rendering /crawl API. Initiates async crawl jobs, polls for completion, and saves results as markdown files. Useful for ingesting documentation sites, knowledge bases, or any web content into your project context. Requires CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN environment variables.
热度
- GitHub 星标
- 33k
- 排名
- #9088
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
owasp-security
33k教你的智能体掌握面向网页应用、API、移动端、容器和 AI 智能体的 OWASP 安全指南,以便发现常见弱点并提出修复建议。
agent-management
33k让你的智能体使用 AI Maestro 命令行工具创建、列出、休眠、唤醒、重命名和删除 AI 智能体,管理每个智能体的生命周期。
agent-messaging
33k让你的智能体使用智能体消息协议,在 AI 智能体之间发送、接收和回复带签名的消息,大部分在你自己的电脑上完成。
docs-search
33k让你的智能体搜索自动生成的代码文档,查找函数签名、类定义和注释,从而在修改代码之前核对真实的 API。