关于 web-scraper
面向研究和数据采集任务的命令行网页抓取技能,使用 BeautifulSoup 和 requests 从网站提取结构化信息。它可按选择器提取页面元素、链接和邮箱,也能按 schema 抽取内容。
主要功能
- 01按 CSS 选择器提取元素
- 02收集站内或外部链接
- 03查找邮箱地址
- 04提取文章或产品数据
- 05提供合规抓取指引
适用场景
- 01比较竞争对手价格
- 02收集目录中的联系信息
- 03审查页面标题与元数据
- 04采集网站文章内容
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ guia-matthieu/ clawfu-skills --skill web-scraper安装后在 Claude Code 中输入/web-scraper确认已加载。
附带文件scripts/main.pyscripts/requirements.txt
详细介绍
网页抓取
使用 BeautifulSoup 和 requests 从网站提取结构化数据——将任意网页转换为可用数据。
何时使用此技能
- 竞品研究 - 抓取定价、功能和定位信息
- 潜在客户开发 - 从目录中提取联系信息
- 内容审查 - 提取标题、链接和元数据
- 价格监控 - 跟踪竞品价格变化
- 数据收集 - 从多个来源收集研究数据
Claude 负责什么,你来决定什么
| Claude 负责 | 你来决定 |
|---|---|
| 构建分析框架 | 战略优先事项 |
| 综合市场数据 | 竞争定位 |
| 识别机会 | 资源分配 |
| 制定战略方案 | 最终战略选择 |
| 提出实施方法 | 执行决策 |
依赖项
pip install beautifulsoup4 requests pandas click lxml
命令
抓取元素
python scripts/main.py scrape https://example.com --selector "h1,h2,p"
python scripts/main.py scrape https://example.com --selector ".product-price"
提取链接
python scripts/main.py links https://example.com
python scripts/main.py links https://example.com --internal-only
提取电子邮件
python scripts/main.py emails https://example.com
python scripts/main.py emails https://example.com --depth 2
提取结构化数据
python scripts/main.py structured https://example.com/article --schema article
python scripts/main.py structured https://example.com/product --schema product
示例
示例 1:抓取竞品定价
python scripts/main.py scrape https://competitor.com/pricing --selector ".price,.plan-name"
# Output:
# Extracted 6 elements
# 1. Starter - $29/mo
# 2. Pro - $99/mo
# 3. Enterprise - Contact us
示例 2:提取文章内容
python scripts/main.py structured https://blog.example.com/post --schema article
# Output: article_data.json
# {
# "title": "How to Scale Your Startup",
# "author": "Jane Doe",
# "date": "2024-01-15",
# "content": "...",
# "word_count": 1523
# }
CSS 选择器参考
| 选择器 | 描述 | 示例 |
|---|---|---|
tag | 元素类型 | h1、p、div |
.class | 类名 | .price、.title |
#id | 元素 ID | #main-content |
tag.class | 带类的标签 | div.product |
tag[attr] | 具有属性 | a[href] |
parent > child | 直接子元素 | ul > li |
tag1, tag2 | 多个元素 | h1, h2, h3 |
合乎道德的抓取准则
- 检查 robots.txt - 遵守网站的抓取政策
- 限制频率 - 不要让服务器过载(1-2 次请求/秒)
- 表明身份 - 使用描述性 User-Agent
- 缓存请求 - 不要重复抓取未发生变化的页面
- 服务条款 - 检查是否允许抓取
技能边界
此技能擅长的方面
- 构建战略分析
- 识别市场机会
- 创建战略框架
- 综合竞争数据
此技能无法做到的事
- 取代市场研究
- 保证战略成功
- 了解竞争对手的专有信息
- 做出高管决策
相关技能
技能元数据
- 模式:centaur
category: automation
subcategory: data-extraction
dependencies: [beautifulsoup4, requests, pandas]
difficulty: intermediate
time_saved: 5+ hours/week
评论
支持 Markdown