代码插件
Scrapling OpenClaw Plugin — 插件工具
v1.0.1The plugin's code, README and runtime instructions are coherent with a web-scraping plugin that shells out to a local Python 'scrapling' CLI and writes crawl output to disk; nothing requests unrelated secrets or installs arbitrary remote binaries, but you must trust the external 'scrapling' Python package you install.
0· 1·0 当前0
版本
latestv1.0.12026/4/5
安装命令
点击复制官方npx clawhub@latest install scrapling-openclaw-plugin
🇨🇳 镜像加速npx clawhub@latest install scrapling-openclaw-plugin --registry https://cn.clawhub-mirror.com
插件文档
Scrapling OpenClaw Plugin
Scrapling 自适应网页爬虫插件 for OpenClaw,提供智能网页抓取能力,内置反检测和动态页面渲染支持。
功能特性
- 🚀 自适应抓取:自动识别反爬策略,智能绕过检测
- 🎨 动态页面支持:基于 Playwright 渲染 JavaScript 页面
- 📝 结构化提取:支持 CSS 选择器、XPath 或 AI 自动提取结构化数据
- 🌐 整站爬取:可配置深度、包含/排除规则的全站爬取
- 🔄 自动重试:失败请求自动重试,提高抓取成功率
- 🛡️ 代理支持:支持 HTTP/HTTPS/SOCKS 代理
- 📦 多格式输出:支持文本、Markdown、JSON 多种输出格式
安装要求
- Python 3.8+
- Scrapling 爬虫框架:
pip install scrapling - Playwright 依赖(可选,用于 JS 渲染):
playwright install chromium
安装插件
- 将插件目录放置到 OpenClaw 的
extensions目录下 - 安装 Node.js 依赖:
npm install - 构建插件:
npm run build - 在 OpenClaw 配置文件中启用插件:
{
"plugins": {
"entries": {
"scrapling-openclaw-plugin": {
"enabled": true,
"config": {
"pythonPath": "python3",
"scraplingPath": "scrapling",
"timeout": 30000,
"retryTimes": 3
}
}
}
}
}工具说明
1. scrapling_fetch - 抓取单个页面
抓取单个网页的内容,支持动态渲染。
参数:
url(必填):要抓取的网页 URLrender_js(可选,默认 false):是否渲染 JavaScriptwait_for_selector(可选):等待指定 CSS 选择器出现后再返回内容proxy(可选):代理服务器地址timeout(可选):请求超时时间(毫秒)return_format(可选,默认 markdown):返回格式,可选 text/markdown/json
示例:
scrapling_fetch({
url: "https://example.com",
render_js: true,
return_format: "markdown"
})2. scrapling_crawl - 整站爬取
从起始 URL 开始爬取整个网站,可配置爬取深度和规则。
参数:
start_url(必填):爬取起始 URLmax_depth(可选,默认 2):最大爬取深度include_patterns(可选):要包含的 URL 正则表达式列表exclude_patterns(可选):要排除的 URL 正则表达式列表render_js(可选,默认 false):是否为所有页面渲染 JavaScriptmax_pages(可选,默认 100):最大爬取页面数output_dir(可选):保存爬取结果的目录proxy(可选):代理服务器地址
示例:
scrapling_crawl({
start_url: "https://example.com",
max_depth: 3,
include_patterns: ["^https://example.com/blog/."],
exclude_patterns: [".*\\.(pdf|zip)$"],
max_pages: 200
})3. scrapling_extract - 提取结构化数据
从网页中提取结构化数据,支持手动指定选择器或 AI 自动提取。
参数:
url(可选):要提取的网页 URL(和 html 二选一)html(可选):要提取的 HTML 内容(和 url 二选一)extract_schema(可选):提取规则,键为字段名,值为 CSS 选择器/XPathauto_extract(可选,默认 false):使用 AI 自动提取数据extract_type(可选,默认 text):提取类型,可选 text/html/attributeattribute_name(可选):当 extract_type 为 attribute 时,指定要提取的属性名render_js(可选,默认 false):是否渲染 JavaScriptproxy(可选):代理服务器地址
示例:
// 手动指定提取规则
scrapling_extract({
url: "https://example.com/products",
extract_schema: {
"title": "h1.product-title",
"price": "span.price",
"description": "div.product-description"
}
})
// AI 自动提取
scrapling_extract({
url: "https://example.com/article",
auto_extract: true
})使用场景
- 内容采集:批量抓取新闻、博客、产品信息等内容
- 数据监测:监测竞争对手网站价格、库存变化
- 搜索引擎:构建自定义搜索引擎的网页抓取模块
- AI 训练数据:收集网页数据用于大模型训练
- 自动化测试:自动测试网站功能和内容正确性
注意事项
- 请遵守目标网站的
robots.txt规则和使用条款 - 合理控制爬取频率,避免对目标网站造成过大压力
- 对于需要登录的网站,请配合 Cookie 或会话管理使用
- 大规模爬取建议使用代理池,避免 IP 被封禁
打赏支持
如果你觉得这个插件对你有帮助,欢迎打赏支持一下开发者~

License
MIT
数据来源:ClawHub ↗ · 中文优化:龙虾技能库