SuperAPI AI 工具集

fetch4ai

通用与其它

查看项目

更新于 10-16 05:53

技能介绍

用途:抓取网页内容并生成干净、可直接供 LLM 使用的 Markdown,去除导航、页脚等噪声;可作为独立命令行工具,也可作为 web-research 工作流的抓取层。

依赖与准备:需先安装 crawl4ai:pip install -U crawl4ai,然后运行 crawl4ai-setup 完成 Playwright 首次设置。

基本用法:脚本路径为 ~/.claude/skills/fetch4ai/scripts/fetch4ai.py,常用参数包括 --url、--format markdown(或 md、json)、--timeout(默认 30 秒)、-o 输出文件、--quiet/-q 静默。可选配置 shell 别名:alias fetch4ai='python ~/.claude/skills/fetch4ai/scripts/fetch4ai.py'。

过滤策略:pruning(默认,按文本密度、链接密度和标签重要性打分,参数 --threshold 默认 0.48、--min-words 默认 5);bm25(按查询相关性抽取,需 --query,--bm25-threshold 默认 1.2);tags(排除指定标签,--excluded-tags,如 nav,footer,aside,header,--word-count-threshold 默认 10);composite(先 pruning 再 bm25,适合长页面高精度抽取)。

输出与进阶:返回 JSON,含 success、url、title、content、links、stats(raw_length、fit_length、reduction_percent)、strategy、metadata(fetch_time、word_count)。支持 --include-links、--include-images、--exclude-external-links、--session-id 多页共享会话、--output 保存文件。失败时返回 success:false 及 error_type(timeout、network、parsing、empty_content)。限制:依赖 crawl4ai 与 Playwright 环境,超时默认 30 秒,页面空内容或 JS 重页面可能失败,资料未提供收费与平台支持信息。