练习开发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

在线或离线llama.cpp安装和模型启动

在线或离线llama.cpp安装和模型启动

该版本安装时间是2025-01-10,因为不同版本可能安装上会有所不同,下面也会讲到。 先说下问题——按照官方文档找不到执行命令llama-cli或./llama-cli 先附上llama.cpp的github地址:https://github.com/ggerganov/llama.cpp,build地址:https://github.com/ggerganov/llama.cpp/blob/master/docs/build.md。不知道你有没有出现这种情况,按照官方文档安装之后,发现根本找不到执行命令llama-cli或./llama-cli,如果没有可以跳过,如果有请按照我的以下流程安装一遍。 下载llama.cpp 我这里使用的是git命令下载: git clone https://github.com/ggerganov/llama.cpp 如果需要在内网服务器中安装,可以下载llama.cpp的源码文件或二进制文件,下载地址:https://github.com/

Paperiii 官网入口:www.paperiii.com——2026抖音爆款AI写作工具

Paperiii 官网入口:www.paperiii.com——2026抖音爆款AI写作工具

今天小编就用一篇文章说清楚在抖音播放量2千万+的2026开年抖音爆款AI写作工具——Paperiii。 一、官网在哪里? 这个是后台私信问小编最多的问题,话不多说,小编直接把官网放这里——www.paperiii.com,需要的家人们自取,也可以点击下方卡片直接跳转。 Paperiii官网http://www.paperiii.com 二、Paperiii是什么? Paperiii 是一款面向学术写作的专业 AI 辅助工具,主打全流程论文支持,且成文在知网的重复率和AI率达标,由于近期山寨仿冒网站增多,大家认准paperiii官网:https://www.paperiii.com,误入山寨仿冒网站不仅可能造成论文数据泄露,还可能被知网记录,影响后续的论文检测与提交。 三、Paperiii能做什么? 1)AI 辅助写作 2)AI 降重 + 降 AIGC 率 3)AI 智能审稿 4)AI

Paperzz 期刊论文智能写作:让学术投稿从 “难产” 到 “高产” 的破局之道

Paperzz 期刊论文智能写作:让学术投稿从 “难产” 到 “高产” 的破局之道

Paperzz-AI官网免费论文查重复率AIGC检测/开题报告/文献综述/论文初稿paperzz - 期刊论文https://www.paperzz.cc/journalArticle 在学术研究的金字塔中,期刊论文是衡量研究者能力的核心标尺,也是学术成果走向同行认可的必经之路。然而,对于大多数科研人而言,期刊论文写作与投稿始终是一道难以逾越的鸿沟:从选题构思到框架搭建,从文献梳理到内容填充,从格式规范到语言润色,每一个环节都充满了挑战。传统的写作模式不仅效率低下,还容易陷入 “反复修改、屡屡被拒” 的循环,让不少研究者在学术道路上步履维艰。 Paperzz 的期刊论文智能写作功能,正是为破解这一困境而生。它以 AI 技术为核心,重构了期刊论文的创作全流程,将选题、框架、内容、格式、润色等环节深度整合,让学术写作从 “个体攻坚” 升级为 “智能协同”。无论是初出茅庐的青年学者,还是经验丰富的资深研究者,都能借助这一工具,大幅提升写作效率与投稿成功率,让学术成果更快、更稳地走向学术舞台。 一、期刊论文写作的

Whisper-WebUI语音转文字工具:2025年最值得投资的效率革命

Whisper-WebUI语音转文字工具:2025年最值得投资的效率革命 【免费下载链接】Whisper-WebUI 项目地址: https://gitcode.com/gh_mirrors/wh/Whisper-WebUI 在数字内容爆炸式增长的时代,语音转文字技术正成为内容创作者、教育工作者和企业用户的必备工具。面对市场上琳琅满目的解决方案,Whisper-WebUI以其独特的技术架构和卓越的性能表现,正在重新定义语音识别的行业标准。这款基于Gradio构建的开源工具,通过深度优化的处理流水线,让语音转录效率实现了质的飞跃。 🔍 传统语音识别面临的三大核心痛点 性能瓶颈问题:传统语音识别工具在处理长音频时往往面临显存占用过高、处理速度缓慢的困扰。原生Whisper在处理10分钟音频时需要消耗超过11GB显存,耗时长达4分30秒,严重制约了实际应用场景。 多源兼容性挑战:从本地文件到在线视频,从实时录音到流媒体内容,用户需要的是能够无缝对接各类音源的一站式解决方案。 后期处理复杂度:单纯的语音转文字远远不够,用户更需要完整的字幕制作、说话人分离、背景音乐处理等配套功能