mcpField
W
web-scraper

web-scraper

github.com/guia-matthieu数据与数据库150583 次安装4 周前更新
代码仓库

关于 web-scraper

面向研究和数据采集任务的命令行网页抓取技能,使用 BeautifulSoup 和 requests 从网站提取结构化信息。它可按选择器提取页面元素、链接和邮箱,也能按 schema 抽取内容。

主要功能

  1. 01按 CSS 选择器提取元素
  2. 02收集站内或外部链接
  3. 03查找邮箱地址
  4. 04提取文章或产品数据
  5. 05提供合规抓取指引

适用场景

  1. 01比较竞争对手价格
  2. 02收集目录中的联系信息
  3. 03审查页面标题与元数据
  4. 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

合乎道德的抓取准则

  1. 检查 robots.txt - 遵守网站的抓取政策
  2. 限制频率 - 不要让服务器过载(1-2 次请求/秒)
  3. 表明身份 - 使用描述性 User-Agent
  4. 缓存请求 - 不要重复抓取未发生变化的页面
  5. 服务条款 - 检查是否允许抓取

技能边界

此技能擅长的方面
  • 构建战略分析
  • 识别市场机会
  • 创建战略框架
  • 综合竞争数据
此技能无法做到的事
  • 取代市场研究
  • 保证战略成功
  • 了解竞争对手的专有信息
  • 做出高管决策

相关技能

技能元数据

  • 模式:centaur
category: automation
subcategory: data-extraction
dependencies: [beautifulsoup4, requests, pandas]
difficulty: intermediate
time_saved: 5+ hours/week

评论

支持 Markdown