0) 清理旧安装删除所有旧文件、旧服务、旧 PATH 设置避免 npm 安装冲突1) 终止任何旧的 OpenClaw 进程taskkill /F /IM openclaw.exe 2$null taskkill /F /IM openclaw* 2$null2) 删除旧安装目录假设你目前安装在这类目录F:\TEcode\ai-docx\.openclawF:\TEcode\ai-docx\openclaw%USERPROFILE%\.openclaw%APPDATA%\npm\node_modules\openclaw*运行Remove-Item -Recurse -Force F:\TEcode\ai-docx\.openclaw Remove-Item -Recurse -Force F:\TEcode\ai-docx\openclaw Remove-Item -Recurse -Force $env:USERPROFILE\.openclaw如果全局安装过openclaw还可以npm uninstall -g openclaw3) 清理 npm 缓存强制npm cache clean --force4) 删除旧 PATH 设置打开 PowerShell → 输入$env:PATH.Split(;) | Select-String openclaw $env:PATH.Split(;) | Select-String npm手工检查系统用户 PATH/系统 PATH 里不要有旧的 openclaw 条目。重新安装openclaw1) 确保 Node.js 环境正确OpenClaw 需要Node.js 22 或更高版本。先检查node -v npm -v如果没有或版本过旧去官方下载安装最新的 Node.js LTS当前至少 v22https://nodejs.org/安装完成后重新打开 PowerShell 验证版本node -v npm -v2) 使用 npm 全局安装 OpenClaw CLI全局安装命令npm install -g openclawlatest注意包名是openclaw不是openclaw/cli。3) 验证安装是否成功关闭所有 PowerShell 窗口重新打开一个新的再运行openclaw --version如果没有输出版本号可能全局 npm bin 路径不在 PATH 中运行npm bin -g把输出的目录手动加到用户环境变量 PATH里。4) 初始化 OpenClaw安装成功后第一次完整配置需要运行 onboarding 向导openclaw onboard这个向导会让你生成默认配置填写 API 密钥Anthropic / OpenAI / Gemini 等配置默认 agent 和 GatewayOpenClaw 安装向导↓OpenClaw 安装向导Personal use acknowledgment选项○ Yes / ● No答案Yes作用确认理解 OpenClaw 默认是个人使用多人共享需额外安全设置。Onboarding mode选项● QuickStart / ○ Manual答案QuickStart作用快速完成初始化后续可通过 openclaw configure 调整配置。Model/auth provider我这里选择了千文会自动跳转到浏览器确认页面Default model after Qwen OAuth选项● Keep current (qwen-portal/coder-model) / ○ Enter model manually / ○ qwen-portal/coder-model / ○ qwen-portal/vision-model答案Keep current (qwen-portal/coder-model)作用保留默认的 qwen-portal/coder-model 模型适合代码和文本处理。Select channel (QuickStart)选项● Telegram / ○ WhatsApp / ○ Discord / … / ○ Skip for now答案Skip for now作用暂不配置聊天平台集成后续可通过 openclaw configure 添加。Search provider选项● Brave Search / ○ Gemini / ○ Grok / … / ○ Skip for now答案Skip for now作用暂不配置搜索提供商保持基础功能。Configure skills now?选项● Yes / ○ No答案No作用跳过技能配置后续可按需添加。Enable hooks?选项◻ Skip for now / ◻ boot-md / ◻ bootstrap-extra-files / ◻ command-logger / ◻ session-memory答案Skip for now作用暂不启用 hooks保持安装干净。Gateway service already installed选项● Restart / ○ Reinstall / ○ Skip答案Reinstall作用重新安装 Gateway 服务保证环境干净和配置正确。How do you want to hatch your bot?选项● Hatch in TUI / ○ Open the Web UI / ○ Do this later答案Do this later作用暂不创建或启动 bot先完成基础安装。Start TUI / Hatch bot after onboarding complete选项Do this later答案Do this later作用完成 onboarding 后暂不启动 TUI 或 bot可随时通过 Web UI 管理 agent。如不想立即运行向导也可以先创建基础配置openclaw init5) 启动 OpenClaw 服务通常启动 Gateway 服务openclaw gateway --port 18789你也可以启动 dashboard自带管理 UIopenclaw dashboard爬取公众号接入一、安装依赖进入任意工具目录例如F:\TEcode\tools\wechat-crawler初始化npm init -y安装依赖npm install playwright安装浏览器npx playwright install二、创建爬取脚本创建文件wechat.js/** * wechat.js * 微信公众号文章爬取脚本Playwright Node.js * * 功能 * - 获取文章标题、作者、正文内容 * - 提取正文中的图片 URL * - 自动清理多余空行 * - 返回 JSON * - 支持命令行参数 URL * * 使用 * node wechat.js 文章URL * * 例如 * node wechat.js https://mp.weixin.qq.com/s/xxxxx */const{chromium}require(playwright);/** * 清理文本去除多余空行和前后空格 * param {string} text * returns {string} */functioncleanText(text){returntext.split(/\r?\n/).map(lineline.trim()).filter(lineline.length0).join(\n);}/** * 爬取微信公众号文章 * param {string} url 公众号文章链接 * returns {Promiseobject} 返回结构化 JSON */asyncfunctionscrape(url){// 启动浏览器constbrowserawaitchromium.launch({headless:true,args:[--disable-blink-featuresAutomationControlled]// 避免被检测});constpageawaitbrowser.newPage();// 访问公众号文章awaitpage.goto(url,{waitUntil:domcontentloaded});// 提取标题、作者、正文、图片constdataawaitpage.evaluate((){consttitledocument.querySelector(#activity-name)?.innerText||;constauthordocument.querySelector(#js_name)?.innerText||;constcontentEldocument.querySelector(#js_content);constcontentcontentEl?.innerText||;// 提取正文图片 URLconstimagescontentEl?Array.from(contentEl.querySelectorAll(img)).map(imgimg.src):[];return{title,author,content,images};});awaitbrowser.close();// 清理正文文本data.contentcleanText(data.content);returndata;}/** * 批量抓取可选 * 输入 URL 数组返回数组 JSON * param {string[]} urls */asyncfunctionscrapeBatch(urls){constresults[];for(consturlofurls){try{constresawaitscrape(url);results.push({url,...res});}catch(err){results.push({url,error:err.message});}}returnresults;}/** * 主函数命令行使用 */(async(){constargsprocess.argv.slice(2);if(args.length0){console.error(请提供微信公众号文章 URL例如);console.error(node wechat.js https://mp.weixin.qq.com/s/xxxxx);process.exit(1);}// 支持单个 URL 或多 URLconsturlsargs;letoutput;if(urls.length1){try{outputawaitscrape(urls[0]);}catch(err){console.error(抓取失败:,err.message);process.exit(1);}}else{outputawaitscrapeBatch(urls);}// 输出 JSONconsole.log(JSON.stringify(output,null,2));})();三、本地运行测试node wechat.js https://mp.weixin.qq.com/s/xxxxx 输出示例 { title: 某篇公众号文章标题, author: 某公众号, content: 文章正文内容... }四、接入openclawOpenClaw 的自定义工具skill/tool可以包装你的脚本让 agent 调用Agent ↓ 调用工具 scrape_wechat ↓ 执行 node wechat.js URL ↓ 返回 JSONtitle, author, content ↓ LLM 总结或进一步处理Agent 目录创建工具假设你的 Agent 路径是F:\TEcode\ai-docx\openclaw\.openclaw\agents\main在tools目录下创建一个文件F:\TEcode\ai-docx\openclaw\.openclaw\agents\main\tools\scrape_wechat.js内容示例import { execSync } from child_process; export default { name: scrape_wechat, description: Fetch a WeChat public article by URL and return structured JSON, parameters: { type: object, properties: { url: { type: string, description: 微信公众号文章链接 } }, required: [url] }, run: async ({ url }) { try { const result execSync(node F:\\TEcode\\tools\\wechat-crawler\\wechat.js ${url}).toString(); return result; } catch (err) { return 抓取失败: ${err.message}; } } };注意路径替换为你本地wechat.js脚本实际存放位置。重新加载 Agent测试调用对agent说我写了一个爬取文章的脚本放在了xxx下请你把它配置为你的技能并重启确保 OpenClaw 检测到新的scrape_wechat工具。之后你可以在 TUI 或 Dashboard 里查看 agent 可用的工具列表。在 Dashboard 对 agent 说抓取这篇文章: https://mp.weixin.qq.com/s/xxxxx返回示例{ title: 文章标题, author: 公众号名称, content: 文章正文内容... }可选自动总结如果希望 agent直接返回摘要而不是原文可以在工具里改写run函数return { summary: 请帮我总结这篇文章\n${result} };或者让 agent 调用 LLMagent.receive(scrape_wechat(url)) agent.summarize()