练习开发Skill——网页内容抓取Skill(website-content-fetch)

练习开发Skill——网页内容抓取Skill(website-content-fetch)
现在使用AI帮我们找一些资料帮我们分析问题的场景多的数不胜数,但是在AI找资料的过程中,我们对AI抓取的内容是不知道,也不可以明确指定范围的,主要是靠模型本身能力去收集,当然也可以增加提示词,加以控制。

当然目前解决方案也有很多:

  • 增加更详细的提示词,描述更细致,控制更精细,过程更明确
  • 同时也有Tavily Search、SearXNG等搜索智能体,可以更好指定搜索参数,如何处理搜索结果等
  • 引用Skills、MCP等丰富大模型能力

了解到这些的时候,想着练习写一个Skills,实现网页内容抓取(其实很多东西都已经实现了,本文就是学习和分享),也了解一下Skills的开发

Skills的项目结构

skill-name/ ├── SKILL.md (唯一必需) │ ├── YAML 格式 (name, description 必须) │ └── Markdown instructions (介绍使用Markdown) └── Bundled Resources (可选的其他内容,和SKILL.md同级) ├── scripts/ - 存放可执行脚本(例如 Python 等) ├── references/ - 存放文档、API说明、领域知识 ├── examples/ - 存放示例文件 ├── evals/ - 存放测试说明 └── assets/ - 准备模板、图标、样板代码。确保格式正确(PPT、Word、图片等) 

SKILL.md元数据介绍

元数据字段:

字段必填说明
nameSkill 显示名称,默认使用目录名,仅支持小写字母、数字和短横线(最长 64 字符)
description技能用途及使用场景,Claude 根据它判断是否自动应用
argument-hint自动补全时显示的参数提示,如 [issue-number]、[filename] [format]
disable-model-invocation设为 true 禁止 Claude 自动触发,仅能手动 /name 调用(默认 false)
user-invocable设为 false 从 / 菜单隐藏,作为后台增强能力使用(默认 true)
allowed-toolsSkill 激活时 Claude 可无授权使用的工具
modelSkill 激活时使用的模型
context设为 fork 时在子代理上下文中运行
agent子代理类型(配合 context: fork 使用)
hooks技能生命周期钩子配置

scripts

Skills采用Prompt + Scripts架构,Scripts必须绑定特定运行时环境

  • Skills的实现多采用Python脚本,也是大模型运行的主要环境
  • Node.js Skills:需配置node_modules及package.json
  • Bash Scripts:仅需基础Shell环境(但可能依赖系统工具包)

开发案例

Python还不太熟悉,用Node写了一个

主要实现的是:获取网页中所有的文本内容,如果有可以识别的媒体文件,将媒体资源的URL获取下来

整体项目目录结构,skillswebsite-content-fetch是本次的skill主目录,我们可以在一个项目中开发多个skill统一放在skills中,在一起维护也可以随时使用和优化其他skill

请添加图片描述

SKILL.md

--- name: website-content-fetch description: Fetch and extract content from websites. Use this skill whenever the user mentions fetching website content, extracting text from web pages, or needing to get content from a URL, even if they don't explicitly ask for a 'website content fetch' skill. --- 

package.json

{"name":"website-content-fetch","version":"1.0.0","description":"fetching website content","main":"scripts/fetch-content.js","scripts":{"test":"node scripts/fetch-content.js"},"keywords":["openclaw","skill","website","content","fetch"],"author":"","license":"MIT","dependencies":{"axios":"^1.6.2","cheerio":"^1.0.0-rc.12"}}

scripts

fetch-content.js

const axios =require("axios");const cheerio =require("cheerio");const path =require("path");const fs =require("fs");/** * Fetch website content * @param {string} url - The URL to fetch * @param {object} options - Optional parameters * @param {string} options.saveDir - Directory to save media files (optional) * @returns {Promise<object>} - The fetched content and metadata */asyncfunctionfetchWebsiteContent(url, options ={}){try{const response =await axios.get(url);const $ = cheerio.load(response.data);// Extract text contentlet content =$("body").text().trim();// Clean up content content = content.replace(/\s+/g," ");// Extract media resourcesconst media ={images:[],videos:[],audios:[],};// Extract images$("img").each((i, elem)=>{const src =$(elem).attr("src");const alt =$(elem).attr("alt")||"";if(src){const absoluteUrl =newURL(src, url).href; media.images.push({url: absoluteUrl,alt: alt,});}});// Extract videos$("video, iframe").each((i, elem)=>{let src =$(elem).attr("src");if(!src &&$(elem).attr("data-src")){ src =$(elem).attr("data-src");}if(src){const absoluteUrl =newURL(src, url).href; media.videos.push({url: absoluteUrl,});}});// Extract audios$("audio").each((i, elem)=>{const src =$(elem).attr("src");if(src){const absoluteUrl =newURL(src, url).href; media.audios.push({url: absoluteUrl,});}});// Save media files if saveDir is providedif(options.saveDir){// Create save directory if it doesn't existif(!fs.existsSync(options.saveDir)){ fs.mkdirSync(options.saveDir,{recursive:true});}// Save imagesfor(let i =0; i < media.images.length; i++){const image = media.images[i];try{const imageResponse =await axios.get(image.url,{responseType:"stream",});const imageName =`image_${i}_${path.basename(newURL(image.url).pathname)}`;const imagePath = path.join(options.saveDir, imageName);const writer = fs.createWriteStream(imagePath); imageResponse.data.pipe(writer);awaitnewPromise((resolve, reject)=>{ writer.on("finish",()=>resolve()); writer.on("error", reject);}); image.localPath = imagePath;}catch(error){ console.error(`Error saving image ${image.url}:`, error.message);}}// Save videosfor(let i =0; i < media.videos.length; i++){const video = media.videos[i];try{const videoResponse =await axios.get(video.url,{responseType:"stream",});const videoName =`video_${i}_${path.basename(newURL(video.url).pathname)}`;const videoPath = path.join(options.saveDir, videoName);const writer = fs.createWriteStream(videoPath); videoResponse.data.pipe(writer);awaitnewPromise((resolve, reject)=>{ writer.on("finish",()=>resolve()); writer.on("error", reject);}); video.localPath = videoPath;}catch(error){ console.error(`Error saving video ${video.url}:`, error.message);}}// Save audiosfor(let i =0; i < media.audios.length; i++){const audio = media.audios[i];try{const audioResponse =await axios.get(audio.url,{responseType:"stream",});const audioName =`audio_${i}_${path.basename(newURL(audio.url).pathname)}`;const audioPath = path.join(options.saveDir, audioName);const writer = fs.createWriteStream(audioPath); audioResponse.data.pipe(writer);awaitnewPromise((resolve, reject)=>{ writer.on("finish",()=>resolve()); writer.on("error", reject);}); audio.localPath = audioPath;}catch(error){ console.error(`Error saving audio ${audio.url}:`, error.message);}}}return{ content,length: content.length, url, media,};}catch(error){ console.error("Error fetching website content:", error);thrownewError(`Failed to fetch content from ${url}: ${error.message}`);}}// If run directly, test the functionif(require.main === module){const url = process.argv[2]||"https://example.com";const saveDir = process.argv[3];const options ={};if(saveDir){ options.saveDir = saveDir;}fetchWebsiteContent(url, options).then((result)=>{ console.log("Fetched content:"); console.log(`URL: ${result.url}`); console.log(`Length: ${result.length} characters`); console.log("Content:"); console.log(result.content);// Display media resources console.log("\nMedia resources:");if(result.media.images.length >0){ console.log("Images:"); result.media.images.forEach((image, index)=>{ console.log(`${index +1}. ${image.url} (alt: ${image.alt})`);if(image.localPath){ console.log(` Saved to: ${image.localPath}`);}});}if(result.media.videos.length >0){ console.log("\nVideos:"); result.media.videos.forEach((video, index)=>{ console.log(`${index +1}. ${video.url}`);if(video.localPath){ console.log(` Saved to: ${video.localPath}`);}});}if(result.media.audios.length >0){ console.log("\nAudios:"); result.media.audios.forEach((audio, index)=>{ console.log(`${index +1}. ${audio.url}`);if(audio.localPath){ console.log(` Saved to: ${audio.localPath}`);}});}}).catch((error)=>{ console.error("Error:", error.message);});} module.exports ={ fetchWebsiteContent };

evals

evals.json

{"skill_name":"website-content-fetch","evals":[{"id":1,"prompt":"Fetch content from https://example.com","expected_output":"Should return the text content of example.com","files":[]},{"id":2,"prompt":"Fetch content from a nonexistent domain","expected_output":"Should throw an error about failed to fetch content","files":[]},{"id":3,"prompt":"Fetch content without providing a URL","expected_output":"Should throw an error about URL being required","files":[]}]}

测试

将开发的skill目录website-content-fetch引入支持skill的AI助手或者开发IDE,此处不赘述,只要website-content-fetch放入对应的skills目录,助手或者IDE都可以识别到。

开发的时候,只需要在项目中,和AI工具说使用website-content-fetch skill为我抓取https://www.baidu.com中的内容即可,比如我使用Trae对话,AI会自动发现该工具,并识别scripts的语言识别到node环境会开始install依赖,再用skill执行任务

请添加图片描述


install成功之后,环境准备就绪,就会按照skill开发的功能执行任务了

请添加图片描述
  • 最后再反复测试结果,调试scripts功能,优化逻辑
  • 丰富SKILL内容,为AI下次识别工具,对skill的功能和逻辑有更好的理解,更精确的执行任务

最后附上Github地址
aubrey-skills

Read more

OpenClaw 全攻略:从入门到精通的 AI 智能体部署指南

OpenClaw 全攻略:从入门到精通的 AI 智能体部署指南

第一部分:认知篇 —— 什么是 OpenClaw? 1.1 定义与定位 OpenClaw(原名 Clawdbot / Moltbot)是一个本地优先、隐私至上、多渠道集成的自托管 AI 助手平台。它标志着人工智能从“对话式交互”迈入“自主行动”的第三阶段。 通俗理解: 传统 AI(如网页版 ChatGPT):你问一句,它答一句,像个顾问。 OpenClaw:你给它一个目标(如“帮我整理本月财报并发送给团队”),它能自己规划步骤、搜索数据、处理文件、发送邮件,像个员工。 1.2 核心架构:App、Gateway 与 CLI 要玩转 OpenClaw,必须理解它的三个核心组件: Gateway(网关)

UnityMCP+Claude+VSCode,构建最强AI游戏开发环境

UnityMCP+Claude+VSCode,构建最强AI游戏开发环境

* 前言 * 一、UnityMCP+Claude+VSCode,构建最强AI 游戏开发环境 * 1.1 介绍 * 1.2 使用说明及下载 * 二、VSCode配置 * 2.1 连接UnityMCP * 2.2 在VSCode中添加插件 * 2.3 Claude安装 * 2.4 VSCode MCP配置 * 2.5 使用Claude开发功能 * 三、相关问题 * 总结 前言 * 本篇文章来介绍使用 UnityMCP+Claude+VSCode,打造一个更智能、高效的游戏开发工作流。 * 借助MCP工具,Claude可以直接与Unity编辑器进行双向指令交互,开发者则可以直接使用自然语言进行Unity游戏开发。 * 这一组合充分利用了AI的代码生成、问题诊断与创意辅助能力,极大提升了Unity项目的开发效率与质量。 一、UnityMCP+Claude+

【前沿解析】2026年3月30日:AI推理能力与国产模型的双重突破——OpenAI o3/o4-mini推理优化与阿里Qwen3.5-Max-Preview盲测登顶重塑全球AI竞争格局

摘要:本文深入解析2026年3月29日至30日AI领域的双重突破。OpenAI深夜发布全新推理模型o3和o4-mini,在ARC-AGI测试中得分暴涨10倍,实现推理时计算与自然语言程序搜索创新;阿里巴巴通义千问Qwen3.5-Max-Preview在权威盲测平台LMArena登顶国产大模型榜首,超越GPT-5.4、Claude 4.5等海外旗舰模型,展示MoE架构与成本效率优势。本文涵盖技术原理、架构设计、代码实现及产业影响分析,为开发者提供全面的技术参考。 关键词:OpenAI o3, o4-mini, 推理优化, 阿里巴巴Qwen3.5-Max-Preview, LMArena盲测, MoE架构, ARC-AGI测试, 国产大模型 一、引言:AI领域迎来双重里程碑 2026年3月的最后一周,人工智能领域再次迎来密集的技术爆破。就在3月29日深夜,OpenAI突袭式发布全新推理模型o3和o4-mini,专门针对ARC-AGI这类"反刷榜"测试进行优化,在ARC-AGI-3测试中得分从GPT-5.4的0.26%直接飙升至2.8%,实现10倍突破。几乎同一

基于开源飞控pix的无人机装调与测试

基于开源飞控pix的无人机装调与测试

文章目录 * 前言 * 硬件使用说明 * 一、Hyper982 RTK模块 * 作为移动站使用 * 通过串口助手设置RTK参数(移动站) * 设置飞控参数(ArduPilot) * 设置飞控参数(PX4) * 二、HyperLte 4G图数传 * 资源下载 * 1、地面站软件和固件可执行文件 * 超维定制版HyperQGC(推荐) * NTRIP功能使用方法 * 基于超维定制版QGC和ArduPilot固件的领航跟随编队 * 多路视频流设置 * MQTT设置 * 地面站设置 * 4G模块配置 * MQTT服务器配置 * 飞控配置 * 海康威视相机云台控制 * Mission Planner地面站 * PX4固件可执行文件 * ArduPilot固件可执行文件 * 2、安装好环境的虚拟机 * 安装虚拟机 *