SuperAPI AI 工具集

scrapling

通用与其它

查看项目

更新于 10-15 15:32

技能介绍

Scrapling 是一个在终端中使用的网站抓取命令行工具,无需编写代码即可获取网页内容。它提供 extract 子命令,用于抓取页面并将选中内容或完整内容保存到文件。

用途与适用场景 Scrapling 适合快速提取网页内容、处理由 JavaScript 渲染的页面,以及应对带有反机器人保护的网站。根据目标页面类型选择不同命令:静态页面、博客、新闻和 API 可使用 get、post、put、delete;JavaScript 渲染页面使用 fetch;Cloudflare 或反机器人保护页面使用 stealthy-fetch。建议从 get 开始,再尝试 fetch,最后尝试 stealthy-fetch。

安装与更新 安装 shell 扩展:uv tool install "scrapling[shell]",然后运行 scrapling install 完成浏览器与指纹的初始化。当版本发布要求更新 Scrapling 及刷新浏览器和指纹时,可执行 uv tool upgrade scrapling 与 scrapling install --force。

安全要求 当抓取内容会被 AI 模型读取时,始终添加 --ai-targeted 选项。该选项会保留页面主体,移除可能包含提示注入的噪声和隐藏内容,剥离注释与零宽字符,并在浏览器命令中启用广告拦截。

输出格式 输出格式由保存文件的扩展名决定:.md 对应 Markdown,.html 对应 HTML,.txt 对应纯文本。为提升可读性建议优先使用 .md,并可配合 --css-selector 减少输出内容。命令执行完成后读取输出文件,随后清理临时文件。

主要能力与选项 所有命令均支持 -s / --css-selector 返回所有匹配元素、--ai-targeted 为 AI 消费净化内容、--proxy 指定代理 URL。HTTP 命令还支持 -H / --headers 可重复的请求头、--cookies 以 name=value; name2=value2 形式提供 cookie、-p / --params 可重复的查询参数、--timeout(秒,默认 30)、--impersonate 指定浏览器指纹(如 chrome 或 firefox)、--follow-redirects / --no-follow-redirects、--verify / --no-verify、--stealthy-headers / --no-stealthy-headers,以及用于 post 和 put 的 --data 与 --json。 fetch 与 stealthy-fetch 额外支持 --headless / --no-headless、--network-idle / --no-network-idle、--disable-resources / --enable-resources、--wait(额外等待毫秒数)、--wait-selector、--timeout(毫秒,默认 30000)、--locale、-H / --extra-headers、--real-chrome / --no-real-chrome、--block-ads / --no-block-ads、--dns-over-https / --no-dns-over-https(使用代理时防止 DNS 泄漏)以及 --executable-path 自定义 Chromium 可执行文件,缺失时回退到 SCRAPLING_EXECUTABLE_PATH。 stealthy-fetch 还额外支持 --solve-cloudflare / --no-solve-cloudflare、--block-webrtc / --allow-webrtc、--allow-webgl / --block-webgl、--hide-canvas / --show-canvas。

帮助与资源 可通过 scrapling extract --help、scrapling extract get --help、scrapling extract fetch --help、scrapling extract stealthy-fetch --help 查看各命令帮助。可用资源包括文档与 GitHub 仓库。