📥 Scrapling-Safe 技能安装指南
目录
1. 前置要求 2. 安装方法 3. 验证安装 4. 使用示例 5. 常见问题解答 6. 快速开始
1. 前置要求
• Python 3.10 或更高版本 • pip 包管理器 • 网络连接 • 足够的磁盘空间(约 2GB)
2. 安装方法
方法 1:一键安装(推荐)⭐
这是最简单的方法,适合大多数用户。
• 安装技能:
clawhub install scrapling-safe• 测试安装:
python3 /home/.openclaw/workspace/skills/scrapling-safe/scrapling.py get "https://quotes.toscrape.com" --output ~/test.json方法 2:分步安装(详细版)
适合想要了解每个步骤的用户。
步骤 1:安装技能 - clawhub install scrapling-safe
步骤 2:安装 Scrapling 依赖 - pip install scrapling[fetchers]
步骤 3:安装浏览器依赖 - scrapling install
步骤 4:测试 - scrapling get "https://quotes.toscrape.com" --output ~/result.json
方法 3:强制重装(如果更新后有问题)
适用于安装后遇到问题需要重置的情况。
• 强制重装技能:clawhub install --force scrapling-safe
• 重新安装依赖:pip install scrapling[fetchers] --break-system-packages
• 重新安装浏览器:scrapling install --force
方法 4:从源码安装(高级用户)
适合有 Git 经验的开发者。
• 克隆仓库:
git clonehttps://clawhub.ai/linshuikeji/scrapling-safe
• 进入目录:
cd scrapling-safe• 安装依赖:
pip install scrapling[fetchers]• 安装浏览器:scrapling install
• 运行技能:
python3 scrapling.py get "https://quotes.toscrape.com" --output ~/result.json3. 验证安装
检查版本
clawhub list测试运行
scrapling get "https://quotes.toscrape.com" --output ~/test.json查看结果
cat ~/test.json验证依赖
python3 -c "import scrapling; print(scrapling.__version__)"4. 使用示例
基本抓取
scrapling get "https://quotes.toscrape.com" --output ~/quotes.json隐身模式
scrapling stealthy "https://quotes.toscrape.com" --output ~/quotes.json浏览器自动化
scrapling dynamic "https://quotes.toscrape.com" --output ~/quotes.json指定 CSS 选择器
scrapling get "https://quotes.toscrape.com" --css-selector ".quote" --output ~/quotes.json提取特定字段
scrapling get "https://quotes.toscrape.com" --css-selector ".quote .text" --output ~/text.json5. 常见问题解答
Q1: 安装后无法运行?
• 检查 Scrapling 是否安装:
python3 -c "import scrapling; print(scrapling.__version__)"• 重新安装:
pip install scrapling[fetchers]• 安装浏览器依赖:
scrapling installQ2: 路径验证失败?
• 确保输出路径在用户主目录
• 正确:~/result.json
• 错误:/etc/result.json
Q3: 依赖冲突?
• 使用 --break-system-packages 参数:
pip install scrapling[fetchers] --break-system-packagesQ4: 版本不是最新的?
• 更新技能:
clawhub update scrapling-safe• 或者强制重装:
clawhub install --force scrapling-safeQ5: 网络连接失败?
• 检查网络连接
• 尝试使用代理:
export HTTP_PROXY="http://proxy.server:port"Q6: 如何更新到最新版本?
clawhub update scrapling-safe• 或者强制重装:
clawhub install --force scrapling-safe6. 快速开始
完整安装清单
前置要求
• Python 3.10+ • pip 包管理器 • 网络连接
安装步骤
1
clawhub install scrapling-safe 2.
pip install scrapling[fetchers] 3.
scrapling install 4. 测试:
scrapling get "https://quotes.toscrape.com"验证安装clawhub listscrapling get "https://quotes.toscrape.com" --output ~/test.jsoncat ~/test.json
夜雨聆风