浏览器

web-fetch

试用

网页数据采集技能。静态页用 requests+BeautifulSoup,JS 渲染页用 Playwright,自动尊重 robots.txt、轮换 User-Agent、限速,输出结构化 JSON/CSV。覆盖垂直领域采集、反爬应对、数据清洗与质量校验。适用于市场调研、竞品监控、公开数据聚合。

它能做什么

网页数据采集技能。静态页用 requests+BeautifulSoup,JS 渲染页用 Playwright,自动尊重 robots.txt、轮换 User-Agent、限速,输出结构化 JSON/CSV。覆盖垂直领域采集、反爬应对、数据清洗与质量校验。适用于市场调研、竞品监控、公开数据聚合。

技能文档

web-fetch — 网页数据采集台

从"一次性 fragilescript"到"可恢复、结构化、守规矩"的采集流程。

选型决策树(先选对工具,再写代码)

场景工具说明
静态 HTML(新闻/博客/Wiki/政府数据)requests + BeautifulSoup + lxml快、轻、免费
JS 渲染 SPA(React/Vue/Angular)Playwright(真实 Chromium)等 JS 渲染后取 DOM
大规模/分布式Scrapy内置并发、节流、管道
不想管浏览器基础设施托管抓取 API远端跑 Chromium,返回渲染 HTML

黄金法则:先查目标站有没有公开 API——更快、更稳、更合规。

标准工作流

1. 合规前置

from urllib.robotparser import RobotFileParser
rp = RobotFileParser(); rp.set_url("https://example.com/robots.txt"); rp.read()
if not rp.can_fetch("*", url):  # 尊重 robots.txt
    ... # 换源或放弃
  • 限速(同域请求间隔随机 1–3s)、不压垮服务器
  • 只采公开数据,避开个人隐私/版权内容

2. 请求层(反爬基础)

  • 真实 UA 轮换、Referer、合理 headers
  • 会话复用(requests.Session)
  • 异常重试 + 退避(网络/4xx/5xx)

3. 解析层

  • CSS 选择器 / XPath 提取目标字段
  • 结构化:每条记录 = 一个 dict,字段命名规范

4. 清洗与校验

  • 数值范围校验(price>0)、文本长度限制、时间格式验证
  • 用 pandas 批量去重、规整

5. 结构化输出

  • JSON(嵌套)或 CSV(扁平),落盘到工作目录

脚本用法

# 静态页:提取所有  链接与标题
python scripts/scrape.py "https://news.ycombinator.com/" --select "span.titleline>a" --attr href --text

# 自定义字段(CSS 选择器 -> 字段名)
python scripts/scrape.py "https://example.com/products" \
  --field "title:.product-card h2" --field "price:.price"

# JS 渲染页(Playwright)
python scripts/scrape.py "https://spa.example.com/" --js --wait ".product-card"

# 输出到文件
python scripts/scrape.py "URL" --field "x:y" --out result.json

# 跳过 robots 检查(仅当你已获授权)
python scripts/scrape.py "URL" --no-robots

反爬应对(分级)

  1. 轮换 UA + 随机延迟 + 会话管理 → 解决大部分基础拦截
  2. Playwright + stealth 补丁 → 绕过 navigator.webdriver 等指纹检测
  3. 住宅代理轮换 → 突破 IP 级封锁
  4. 行为拟真(非均匀 timing、真实交互)→ 现代反爬看"行为"而非"速度"

自我进化学习系统

本技能用 scripts/learner.py 记录每次采集成败与高频失败模式(封禁类型、选择器失效等):

python scripts/learner.py record <技能目录> --capability 反爬绕过 --note "目标站需Playwright+stealth"
python scripts/learner.py record <技能目录> --capability 选择器解析 --fail --error 选择器失效 --note "改版后 .price 变 .cost"
python scripts/learner.py insight <技能目录>
python scripts/learner.py reflect <技能目录>

记忆落盘 learned_patterns.json,跨会话积累,使本技能越用越抗变、越用越准。

安全边界

  • 严守 robots.txt 与目标站 ToS;不采集个人信息、密级数据、版权内容。
  • 默认限速,避免对目标站造成过大负载。
  • 不将采集能力用于绕过付费墙或大规模攻击性抓取。

相关技能

根据目标 URL 生成可直接运行的 Python 爬虫脚本,覆盖选型、JS 逆向与反爬处理。

作者 末心3 次安装

Web extraction for LLMs and agents. Scrape, crawl, map, search, extract, summarize, diff, monitor, and research any URL into clean Markdown, text, or JSON, i...

3 次安装

使用 Playwright headed 模式 + 真实系统浏览器抓取微信公众号文章。 当用户给出 mp.weixin.qq.com 链接、说要抓取/下载公众号文章、 或遇到"环境异常"验证页时,必须使用本技能。 本技能会弹出真实浏览器窗口绕过微信反爬,提取文章标题、作者、正文, 并同时保存 .md 和 .htm...

Extract structured JSON from web pages, search engines, and entire sites in ONE call — {title, summary, sections, key_metrics, outgoing_links, author, date, page_type, ...} fields, no second LLM pass to parse HTML. Six endpoints: scrape (single URL), scrape-interactive (JS-rendered pages with click/scroll/type), search (Google SERP + deep-scrape), map (URL discovery), crawl + crawl-status (async recursive crawl). Markdown/raw HTML on request. USE when the user needs page DATA — product pricing/specs, article fields, link graphs, JS-heavy SPAs, Google results with content. Prefer over browser-act (automation/screenshots) and WebFetch (static, no JS, no structured fields). Not for citation-rich research (use deep-research). Trigger (EN): scrape this URL, extract data from page, crawl this site, deep-scrape search results, map a domain's URLs, render this JS page. 触发词:抓取/爬取/网页提取/结构化抽取/搜索带内容/全站爬取/JS 渲染抓取/点击后抓取. Requires ZOODATA_API_KEY (free key: https://zoodata.ai/en/api-keys).

⚠️ 前置依赖:browser-skill(bsk CLI + Chromium 扩展,需先在 WorkBuddy 插件市场安装)。 网页登录态数据挖掘器(通用版)。复用用户已登录浏览器的登录态(cookies),通过 browser-skill 驱动真实浏览器抓取网页版数据,把「人肉复制粘贴」变成程序化采集,零 API 成本获取企业工商、 人物图谱、股权穿透、财务等深度数据,并输出结构化 JSON 或 HTML 报告。当目标网站同时提供 「官方 MCP/API(按次计费)」与「网页版(会员展示)」时,还能额外绕开 API 积分计费。 采用「通用方法论 + 站点适配器(recipes)」可插拔架构,内置企查查适配器,可扩展天眼查、 爱企查、国家企业信用信息公示系统等任意有「网页版 + 会员登录态」的站点。当用户需要查企业、 查老板、查股东、查实控人、股权穿透、对外投资、企业尽调、供应商背调、批量采集时使用。 触发词:查企业、查老板、查股东、查实控人、股权穿透、对外投资、企业尽调、 工商信息、人物图谱、网页抓取、登录态抓取、批量采集、数据挖掘。

一个模型上下文协议服务器,提供网页内容抓取功能,将HTML转换为Markdown以便于处理。适用于需要从网页提取和处理内容的场景。