mcpField
X
xcrawl-crawl

xcrawl-crawl

github.com/xcrawl-api数据与数据库450214 次安装32 周前更新
代码仓库

关于 xcrawl-crawl

xcrawl-crawl 是通过 XCrawl Crawl API 执行全站或限定范围爬取的技能,支持设置爬取边界和输出格式、轮询任务状态,并原样返回 API 响应。

主要功能

  1. 01全站或限定范围爬取
  2. 02URL 包含与排除规则
  3. 03配置深度和页面上限
  4. 04支持多种输出格式
  5. 05轮询任务状态

适用场景

  1. 01爬取网站指定路径
  2. 02以 Markdown、链接等格式收集页面
  3. 03跟踪爬取任务直至完成

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/xcrawl-api/xcrawl-skills --skill xcrawl-crawl

安装后在 Claude Code 中输入/xcrawl-crawl确认已加载。

详细介绍

XCrawl Crawl

概述

此技能通过 XCrawl Crawl API 执行整站或指定范围的爬取。 默认行为是原样透传:直接返回上游 API 的响应正文。

必需的本地配置

使用此技能前,用户必须创建本地配置文件,并将 XCRAWL_API_KEY 写入其中。

路径:~/.xcrawl/config.json

{
  "XCRAWL_API_KEY": "<your_api_key>"
}

只能从本地配置文件读取 API 密钥。不得要求设置全局环境变量。

积分与账户设置

使用 XCrawl API 会消耗积分。 如果用户没有账户或可用积分,请引导他们前往 https://dash.xcrawl.com/ 注册。 注册后,他们可以先启用免费的 1000 积分套餐,再发送请求。

工具权限策略

仅请求 curl 和 node 的运行时权限。 不得请求 Python、Shell 辅助脚本或其他运行时权限。

API 接口

  • 开始爬取:POST /v1/crawl
  • 读取结果:GET /v1/crawl/{crawl_id}
  • 基础 URL:https://run.xcrawl.com
  • 必需的请求头:Authorization: Bearer <XCRAWL_API_KEY>

使用示例

cURL(创建 + 获取结果)
API_KEY="$(node -e "const fs=require('fs');const p=process.env.HOME+'/.xcrawl/config.json';const k=JSON.parse(fs.readFileSync(p,'utf8')).XCRAWL_API_KEY||'';process.stdout.write(k)")"

CREATE_RESP="$(curl -sS -X POST "https://run.xcrawl.com/v1/crawl" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_KEY}" \
  -d '{"url":"https://example.com","crawler":{"limit":100,"max_depth":2},"output":{"formats":["markdown","links"]}}')"

echo "$CREATE_RESP"

CRAWL_ID="$(node -e 'const s=process.argv[1];const j=JSON.parse(s);process.stdout.write(j.crawl_id||"")' "$CREATE_RESP")"

curl -sS -X GET "https://run.xcrawl.com/v1/crawl/${CRAWL_ID}" \
  -H "Authorization: Bearer ${API_KEY}"
Node
node -e '
const fs=require("fs");
const apiKey=JSON.parse(fs.readFileSync(process.env.HOME+"/.xcrawl/config.json","utf8")).XCRAWL_API_KEY;
const body={url:"https://example.com",crawler:{limit:300,max_depth:3,include:["/docs/.*"],exclude:["/blog/.*"]},request:{locale:"ja-JP"},output:{formats:["markdown","links","json"]}};
fetch("https://run.xcrawl.com/v1/crawl",{
  method:"POST",
  headers:{"Content-Type":"application/json",Authorization:`Bearer ${apiKey}`},
  body:JSON.stringify(body)
}).then(async r=>{console.log(await r.text());});
'

请求参数

请求端点和请求头
  • 端点:POST https://run.xcrawl.com/v1/crawl
  • 请求头:
  • Content-Type: application/json
  • Authorization: Bearer <api_key>
请求正文:顶层字段
字段类型必填默认值说明
urlstring是-网站入口 URL
crawlerobject否-爬虫配置
proxyobject否-代理配置
requestobject否-请求配置
js_renderobject否-JS 渲染配置
outputobject否-输出配置
webhookobject否-异步回调配置
crawler
字段类型必填默认值说明
limitinteger否100最大页面数
includestring[]否-仅包含匹配的 URL(支持正则表达式)
excludestring[]否-排除匹配的 URL(支持正则表达式)
max_depthinteger否3距离入口 URL 的最大深度
include_entire_domainboolean否false爬取整个网站,而非仅爬取子路径
include_subdomainsboolean否false包含子域名
include_external_linksboolean否false包含外部链接
sitemapsboolean否true使用网站站点地图
proxy
字段类型必填默认值说明
locationstring否USISO-3166-1 alpha-2 国家代码,例如 US / JP / SG
sticky_sessionstring否自动生成粘性会话 ID;相同 ID 会尝试复用出口节点
request
字段类型必填默认值说明
localestring否en-US,en;q=0.9影响 Accept-Language
devicestring否desktopdesktop / mobile;影响 UA 和视口
cookiesobject map否-Cookie 键值对
headersobject map否-请求头键值对
only_main_contentboolean否true仅返回主要内容
block_adsboolean否true尝试屏蔽广告资源
skip_tls_verificationboolean否true跳过 TLS 验证
js_render
字段类型必填默认值说明
enabledboolean否true启用浏览器渲染
wait_untilstring否loadload / domcontentloaded / networkidle
viewport.widthinteger否-视口宽度(桌面端 1920,移动端 402)
viewport.heightinteger否-视口高度(桌面端 1080,移动端 874)
output
字段类型必填默认值描述
formatsstring[]否["markdown"]输出格式
screenshotstring否viewportfull_page / viewport(仅当 formats 包含 screenshot 时)
json.promptstring否-提取提示词
json.json_schemaobject否-JSON Schema

output.formats 枚举值:

  • html
  • raw_html
  • markdown
  • links
  • summary
  • screenshot
  • json
webhook
字段类型必填默认值描述
urlstring否-回调 URL
headersobject map否-自定义回调标头
eventsstring[]否["started","completed","failed"]事件:started / completed / failed

响应参数

创建响应(POST /v1/crawl)
字段类型描述
crawl_idstring任务 ID
endpointstring始终为 crawl
versionstring版本
statusstring始终为 pending
结果响应(GET /v1/crawl/{crawl_id})
字段类型描述
crawl_idstring任务 ID
endpointstring始终为 crawl
versionstring版本
statusstringpending / crawling / completed / failed
urlstring入口 URL
dataobject[]每页结果数组
started_atstring开始时间(ISO 8601)
ended_atstring结束时间(ISO 8601)
total_credits_usedinteger使用的总额度

data[] 字段遵循 output.formats:

  • html、raw_html、markdown、links、summary、screenshot、json
  • metadata(页面元数据)
  • traffic_bytes
  • credits_used
  • credits_detail

工作流

  1. 确认业务目标和抓取边界。
  • 明确需要哪些内容、必须排除哪些内容,以及完成信号是什么。
  1. 起草范围明确的抓取请求。
  • 尽量设置明确的限制和路径约束。
  1. 启动抓取并记录任务元数据。
  • 记录 crawl_id、初始状态和请求负载。
  1. 轮询 GET /v1/crawl/{crawl_id},直至进入终止状态。
  • 跟踪 pending、crawling、completed 或 failed 状态。
  1. 返回原始创建/结果响应。
  • 除非用户明确要求,否则不要合成衍生摘要。

输出约定

返回:

  • 端点流程(POST /v1/crawl + GET /v1/crawl/{crawl_id})
  • 创建请求使用的 request_payload
  • 创建调用的原始响应正文
  • 结果调用的原始响应正文
  • 请求失败时的错误详情

除非用户明确要求摘要,否则不要生成摘要。

防护措施

  • 未设置明确约束时,绝不执行无界抓取。
  • 不要将推测的页面数量作为最终覆盖范围呈现。
  • 不要在核心逻辑中硬编码特定提供商的工具架构。
  • 相关时,应指出政策、法律或网站使用方面的风险。

评论

支持 Markdown