Skip to content
Back to search

wechat-article-extractor

Extract metadata and content from WeChat Official Account articles. Use when user needs to parse WeChat article URLs (mp.weixin.qq.com), extract article info (title, author, content, publish time, cover image), or convert WeChat articles to structured data. Supports various article types including posts, videos, images, voice messages, and reposts.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/freestylefly-wechat-article-extractor-skill/badge.svg)](/listings/freestylefly-wechat-article-extractor-skill)

HTML

<a href="/listings/freestylefly-wechat-article-extractor-skill"><img src="/api/listings/freestylefly-wechat-article-extractor-skill/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

这是一个 Claude Code Skill,可以通过以下方式安装:

通过 Claude Code 安装(推荐)

在 Claude Code 中运行:

/skill install wechat-article-extractor

或指定目录安装:

/skill install /path/to/wechat-article-extractor-skill

手动克隆安装

git clone https://github.com/yourusername/wechat-article-extractor-skill.git
cd wechat-article-extractor-skill
npm install

然后在 Claude Code 中将该目录作为 Skill 加载。

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 143 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. ---
  2. name: wechat-article-extractor
  3. description: Extract metadata and content from WeChat Official Account articles. Use when user needs to parse WeChat article URLs (mp.weixin.qq.com), extract article info (title, author, content, publish time, cover image), or convert WeChat articles to structured data. Supports various article types including posts, videos, images, voice messages, and reposts.
  4. ---
  5. # WeChat Article Extractor
  6. Extract metadata and content from WeChat Official Account (微信公众号) articles.
  7. ## Capabilities
  8. - Parse WeChat article URLs (`mp.weixin.qq.com`)
  9. - Extract article metadata: title, author, description, publish time
  10. - Extract account info: name, avatar, alias, description
  11. - Get article content (HTML)
  12. - Get cover image URL
  13. - Support multiple article types: post, video, image, voice, text, repost
  14. - Handle various error cases: deleted content, expired links, access limits
  15. ## Usage
  16. ### Basic Extraction from URL
  17. ```javascript
  18. const { extract } = require('./scripts/extract.js');
  19. const result = await extract('https://mp.weixin.qq.com/s?__biz=...');
  20. // Returns: { done: true, code: 0, data: {...} }
  21. ```
  22. ### Extraction from HTML
  23. ```javascript
  24. const html = await fetch(url).then(r => r.text());
  25. const result = await extract(html, { url: sourceUrl });
  26. ```
  27. ### Options
  28. ```javascript
  29. const result = await extract(url, {
  30. shouldReturnContent: true, // Return HTML content (default: true)
  31. shouldReturnRawMeta: false, // Return raw metadata (default: false)
  32. shouldFollowTransferLink: true, // Follow migrated account links (default: true)
  33. shouldExtractMpLinks: false, // Extract embedded mp.weixin links (default: false)
  34. shouldExtractTags: false, // Extract article tags (default: false)
  35. shouldExtractRepostMeta: false // Extract repost source info (default: false)
  36. });
  37. ```
  38. ## Response Format
  39. ### Success Response
  40. ```javascript
  41. {
  42. done: true,
  43. code: 0,
  44. data: {
  45. // Account info
  46. account_name: "公众号名称",
  47. account_alias: "微信号",
  48. account_avatar: "头像URL",
  49. account_description: "功能介绍",
  50. account_id: "原始ID",
  51. account_biz: "biz参数",
  52. account_biz_number: 1234567890,
  53. account_qr_code: "二维码URL",
  54. // Article info
  55. msg_title: "文章标题",
  56. msg_desc: "文章摘要",
  57. msg_content: "HTML内容",
  58. msg_cover: "封面图URL",
  59. msg_author: "作者",
  60. msg_type: "post", // post|video|image|voice|text|repost
  61. msg_has_copyright: true,
  62. msg_publish_time: Date,
  63. msg_publish_time_str: "2024/01/15 10:30:00",
  64. // Link params
  65. msg_link: "文章链接",
  66. msg_source_url: "阅读原文链接",
  67. msg_sn: "sn参数",
  68. msg_mid: 1234567890,
  69. msg_idx: 1
  70. }
  71. }
  72. ```
  73. ### Error Response
  74. ```javascript
  75. {
  76. done: false,
  77. code: 1001,
  78. msg: "无法获取文章信息"
  79. }
  80. ```
  81. ## Error Codes
  82. | Code | Message | Description |
  83. |------|---------|-------------|
  84. | 1000 | 文章获取失败 | General failure |
  85. | 1001 | 无法获取文章信息 | Missing title or publish time |
  86. | 1002 | 请求失败 | HTTP request failed |
  87. | 1003 | 响应为空 | Empty response |
  88. | 1004 | 访问过于频繁 | Rate limited |
  89. | 1005 | 脚本解析失败 | Script parsing error |
  90. | 1006 | 公众号已迁移 | Account migrated |
  91. | 2001 | 请提供文章内容或链接 | Missing input |
  92. | 2002 | 链接已过期 | Link expired |
  93. | 2003 | 内容涉嫌侵权 | Content removed (copyright) |
  94. | 2004 | 无法获取迁移后的链接 | Migration link failed |
  95. | 2005 | 内容已被发布者删除 | Content deleted by author |
  96. | 2006 | 内容因违规无法查看 | Content blocked |
  97. | 2007 | 内容发送失败 | Failed to send |
  98. | 2008 | 系统出错 | System error |
  99. | 2009 | 不支持的链接 | Unsupported URL |
  100. | 2010 | 内容获取失败 | Content fetch failed |
  101. | 2011 | 涉嫌过度营销 | Marketing/spam content |
  102. | 2012 | 账号已被屏蔽 | Account blocked |
  103. | 2013 | 账号已自主注销 | Account deleted |
  104. | 2014 | 内容被投诉 | Content reported |
  105. | 2015 | 账号处于迁移流程中 | Account migrating |
  106. | 2016 | 冒名侵权 | Impersonation |
  107. ## Dependencies
  108. Required npm packages:
  109. - `cheerio` - HTML parsing
  110. - `dayjs` - Date formatting
  111. - `request-promise` - HTTP requests
  112. - `qs` - Query string parsing
  113. - `lodash.unescape` - HTML entities
  114. ## Notes
  115. - Handles various WeChat page structures and anti-scraping measures
  116. - Automatically detects article type from page content
  117. - Supports extracting from Sogou WeChat search results (`weixin.sogou.com`)
  118. - Some fields may be null depending on article type and page structure
README.md · README · 304 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # WeChat Article Extractor
  2. [![Node.js](https://img.shields.io/badge/Node.js-14+-green.svg)](https://nodejs.org/)
  3. [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
  4. 一个 Claude Code Skill,用于提取微信公众号文章的元数据和内容。支持多种文章类型,包括图文、视频、图片集、语音和转载文章。当用户需要提供微信公众号文章链接(mp.weixin.qq.com)时,Claude 会自动触发此 Skill 来提取文章信息。
  5. ## 功能特性
  6. - 解析微信公众号文章 URL (`mp.weixin.qq.com`)
  7. - 提取文章元数据:标题、作者、摘要、发布时间
  8. - 获取公众号信息:名称、头像、微信号、功能介绍
  9. - 提取文章内容(HTML 格式)
  10. - 获取封面图片 URL
  11. - 支持多种文章类型:图文、视频、图片集、语音、纯文字、转载
  12. - 处理各种异常情况:内容删除、链接过期、访问限制、账号迁移等
  13. - 支持搜狗微信搜索结果的解析 (`weixin.sogou.com`)
  14. - 可选提取文章标签和内嵌链接
  15. ## 安装
  16. 这是一个 Claude Code Skill,可以通过以下方式安装:
  17. ### 通过 Claude Code 安装(推荐)
  18. 在 Claude Code 中运行:
  19. ```
  20. /skill install wechat-article-extractor
  21. ```
  22. 或指定目录安装:
  23. ```
  24. /skill install /path/to/wechat-article-extractor-skill
  25. ```
  26. ### 手动克隆安装
  27. ```bash
  28. git clone https://github.com/yourusername/wechat-article-extractor-skill.git
  29. cd wechat-article-extractor-skill
  30. npm install
  31. ```
  32. 然后在 Claude Code 中将该目录作为 Skill 加载。
  33. ## 使用方法
  34. ### 基本用法 - 从 URL 提取
  35. ```javascript
  36. const { extract } = require('./scripts/extract.js');
  37. async function main() {
  38. const url = 'https://mp.weixin.qq.com/s?__biz=...&mid=...&idx=...&sn=...';
  39. const result = await extract(url);
  40. if (result.done) {
  41. console.log('文章标题:', result.data.msg_title);
  42. console.log('公众号:', result.data.account_name);
  43. console.log('发布时间:', result.data.msg_publish_time_str);
  44. } else {
  45. console.error('提取失败:', result.msg);
  46. }
  47. }
  48. main();
  49. ```
  50. ### 从 HTML 内容提取
  51. 如果你已经获取了页面 HTML,可以直接传入:
  52. ```javascript
  53. const { extract } = require('./scripts/extract.js');
  54. async function main() {
  55. const html = await fetch(url).then(r => r.text());
  56. const result = await extract(html, { url: sourceUrl });
  57. console.log(result);
  58. }
  59. main();
  60. ```
  61. ### 高级选项
  62. ```javascript
  63. const result = await extract(url, {
  64. shouldReturnContent: true, // 返回 HTML 内容(默认:true)
  65. shouldReturnRawMeta: false, // 返回原始元数据(默认:false)
  66. shouldFollowTransferLink: true, // 自动跟随迁移后的公众号链接(默认:true)
  67. shouldExtractMpLinks: false, // 提取内嵌的微信公众号链接(默认:false)
  68. shouldExtractTags: false, // 提取文章标签(默认:false)
  69. shouldExtractRepostMeta: false // 提取转载来源信息(默认:false)
  70. });
  71. ```
  72. ## 响应格式
  73. ### 成功响应
  74. ```javascript
  75. {
  76. done: true,
  77. code: 0,
  78. data: {
  79. // 公众号信息
  80. account_name: "公众号名称",
  81. account_alias: "微信号",
  82. account_avatar: "头像URL",
  83. account_description: "功能介绍",
  84. account_id: "原始ID",
  85. account_biz: "biz参数",
  86. account_biz_number: 1234567890,
  87. account_qr_code: "二维码URL",
  88. // 文章信息
  89. msg_title: "文章标题",
  90. msg_desc: "文章摘要",
  91. msg_content: "HTML内容",
  92. msg_cover: "封面图URL",
  93. msg_author: "作者",
  94. msg_type: "post", // post|video|image|voice|text|repost
  95. msg_has_copyright: true,
  96. msg_publish_time: Date,
  97. msg_publish_time_str: "2024/01/15 10:30:00",
  98. // 链接参数
  99. msg_link: "文章链接",
  100. msg_source_url: "阅读原文链接",
  101. msg_sn: "sn参数",
  102. msg_mid: 1234567890,
  103. msg_idx: 1
  104. }
  105. }
  106. ```
  107. ### 错误响应
  108. ```javascript
  109. {
  110. done: false,
  111. code: 1001,
  112. msg: "无法获取文章信息"
  113. }
  114. ```
  115. ## 错误代码表
  116. | 代码 | 错误信息 | 说明 |
  117. |------|----------|------|
  118. | 1000 | 文章获取失败 | 一般性失败 |
  119. | 1001 | 无法获取文章信息 | 缺少标题或发布时间 |
  120. | 1002 | 请求失败 | HTTP 请求失败 |
  121. | 1003 | 响应为空 | 空响应 |
  122. | 1004 | 访问过于频繁 | 被限流 |
  123. | 1005 | 脚本解析失败 | 页面脚本解析错误 |
  124. | 1006 | 公众号已迁移 | 账号已迁移,包含新链接 |
  125. | 2001 | 请提供文章内容或链接 | 缺少输入参数 |
  126. | 2002 | 链接已过期 | 链接已失效 |
  127. | 2003 | 内容涉嫌侵权 | 内容因侵权被移除 |
  128. | 2004 | 无法获取迁移后的链接 | 迁移链接获取失败 |
  129. | 2005 | 内容已被发布者删除 | 作者已删除内容 |
  130. | 2006 | 内容因违规无法查看 | 内容被平台屏蔽 |
  131. | 2007 | 内容发送失败 | 发送失败 |
  132. | 2008 | 系统出错 | 系统错误 |
  133. | 2009 | 不支持的链接 | URL 格式不支持 |
  134. | 2010 | 内容获取失败 | 内容获取失败 |
  135. | 2011 | 涉嫌过度营销 | 营销/垃圾内容 |
  136. | 2012 | 账号已被屏蔽 | 账号被封禁 |
  137. | 2013 | 账号已自主注销 | 账号已注销 |
  138. | 2014 | 内容被投诉 | 内容被举报 |
  139. | 2015 | 账号处于迁移流程中 | 账号正在迁移 |
  140. | 2016 | 冒名侵权 | 冒充侵权 |
  141. ## 支持的文章类型
  142. | 类型 | 说明 | msg_type |
  143. |------|------|----------|
  144. | 图文 | 普通图文文章 | `post` |
  145. | 视频 | 视频内容 | `video` |
  146. | 图片集 | 多张图片展示 | `image` |
  147. | 语音 | 音频内容 | `voice` |
  148. | 纯文字 | 无标题文字内容 | `text` |
  149. | 转载 | 转载他人文章 | `repost` |
  150. ## 项目结构
  151. ```
  152. wechat-article-extractor-skill/
  153. ├── scripts/
  154. │ ├── extract.js # 核心提取逻辑
  155. │ └── errors.js # 错误代码定义
  156. ├── SKILL.md # Skill 定义文件(Claude Skill 格式,包含触发条件和描述)
  157. ├── package.json # 项目配置
  158. └── README.md # 本文件
  159. ```
  160. ## 依赖项
  161. - `cheerio` - 服务端 HTML 解析
  162. - `dayjs` - 日期格式化
  163. - `request-promise` - HTTP 请求
  164. - `qs` - 查询字符串解析
  165. - `lodash.unescape` - HTML 实体解码
  166. ## 注意事项
  167. 1. **频率限制**: 频繁请求可能会导致 IP 被暂时封禁,建议添加适当的延迟
  168. 2. **页面结构**: 微信页面结构可能会变化,如遇问题请检查是否为最新版本
  169. 3. **Cookie**: 某些文章可能需要登录才能访问完整内容
  170. 4. **反爬措施**: 请遵守微信的使用条款,合理使用本工具
  171. ## 示例应用
  172. ### 批量提取文章
  173. ```javascript
  174. const { extract } = require('./scripts/extract.js');
  175. async function batchExtract(urls) {
  176. const results = [];
  177. for (const url of urls) {
  178. try {
  179. const result = await extract(url);
  180. if (result.done) {
  181. results.push({
  182. title: result.data.msg_title,
  183. author: result.data.account_name,
  184. publishTime: result.data.msg_publish_time_str
  185. });
  186. }
  187. // 添加延迟避免被限流
  188. await new Promise(r => setTimeout(r, 1000));
  189. } catch (err) {
  190. console.error(`提取失败: ${url}`, err.message);
  191. }
  192. }
  193. return results;
  194. }
  195. const urls = [
  196. 'https://mp.weixin.qq.com/s?__biz=...',
  197. 'https://mp.weixin.qq.com/s?__biz=...'
  198. ];
  199. batchExtract(urls).then(console.log);
  200. ```
  201. ### 保存为 Markdown
  202. ```javascript
  203. const { extract } = require('./scripts/extract.js');
  204. const fs = require('fs');
  205. async function saveAsMarkdown(url, filename) {
  206. const result = await extract(url);
  207. if (!result.done) {
  208. console.error('提取失败:', result.msg);
  209. return;
  210. }
  211. const { data } = result;
  212. const markdown = `
  213. # ${data.msg_title}
  214. > 作者: ${data.msg_author || data.account_name}
  215. > 公众号: ${data.account_name}
  216. > 发布时间: ${data.msg_publish_time_str}
  217. ${data.msg_content}
  218. ---
  219. 原文链接: [${data.msg_link}](${data.msg_link})
  220. `;
  221. fs.writeFileSync(filename, markdown);
  222. console.log(`已保存: ${filename}`);
  223. }
  224. saveAsMarkdown('https://mp.weixin.qq.com/s?__biz=...', 'article.md');
  225. ```
  226. ## 许可证
  227. [MIT](LICENSE)
  228. ## 贡献
  229. 欢迎提交 Issue 和 Pull Request!
  230. ## 更新日志
  231. ### v1.0.0
  232. - 初始版本发布
  233. - 支持基本的文章信息提取
  234. - 支持多种文章类型
  235. - 完善的错误处理机制

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.