File contents IT之家文章提取器
从 IT之家 (ithome.com) 网站提取文章内容、元数据和图片。
功能
fetch_article
获取单篇 IT之家文章的完整内容。
参数:
url (必需): IT之家文章 URL,格式如 https://www.ithome.com/0/663/928.htm
format_summary (可选): 是否生成可读的文本摘要,默认 false
返回数据:
success: 是否成功提取
title: 文章标题
description: 文章摘要(meta description)
keywords: 关键词标签
date: 发布日期时间(格式:YYYY/MM/DD HH:MM:SS)
author: 作者姓名
editor: 责编姓名
source: 来源(通常为"IT之家")
content: 文章正文内容(纯文本)
images: 图片列表,包含 URL、alt 文本、title
category_id: 分类 ID(从 URL 提取)
article_id: 文章 ID(从 URL 提取)
summary: 格式化的摘要文本(当 format_summary=true 时)
示例:
result = await execute({
'function': 'fetch_article',
'url': 'https://www.ithome.com/0/663/928.htm',
'format_summary': True
})
fetch_articles
批量获取多篇文章,支持并发请求。
参数:
返回数据:
success: 总体执行状态
total: 总数量
successful: 成功数量
failed: 失败数量
articles: 文章数据列表
示例:
result = await execute({
'function': 'fetch_articles',
'urls': [
'https://www.ithome.com/0/663/928.htm',
'https://www.ithome.com/0/521/657.htm'
]
})
URL 格式
IT之家文章 URL 格式为:
https://www.ithome.com/{category_id}/{article_id}.htm
例如:
https://www.ithome.com/0/663/928.htm (category_id=663, article_id=928)
https://www.ithome.com/0/521/657.htm (category_id=521, article_id=657)
提取字段说明
字段
说明
示例值
title
文章标题
"2499 元起,小米 Redmi K60 发布:..."
date
发布时间
"2022/12/27 20:03:58"
author
作者
"汪淼"
editor
责编
"汪淼"
source
来源
"IT之家"
keywords
关键词
"Redmi K60"
content
正文内容
完整文章内容(纯文本)
images
图片列表
[{"url": "...", "alt": ""}]
技术实现
使用 aiohttp 进行异步 HTTP 请求
使用 BeautifulSoup 进行 HTML 解析
提取 <h1> 标签作为标题
提取 #paragraph 元素作为正文内容
通过特定的 span ID(pubtime_baidu, author_baidu, editor_baidu)提取元数据
支持 lazy-load 图片(data-original 属性)
错误处理
无效域名返回错误信息
URL 格式不正确返回错误信息
HTTP 错误(如 404, 500)返回状态码
网络超时返回超时错误
所有错误不会抛出异常,而是返回包含 success: false 和 error 字段的结果
注意事项
内容提取为纯文本,会移除 HTML 标签
图片 URL 会自动转换为绝对路径
部分文章可能缺少某些元数据字段(作者、责编等)
正文内容包含完整的 \n 分隔符
1 --- 2 name: www-ithome-com 3 description: IT之家文章提取器 4 --- 5 # IT之家文章提取器 6 7 从 IT之家 (ithome.com) 网站提取文章内容、元数据和图片。 8 9 ## 功能 10 11 ### fetch_article 12 13 获取单篇 IT之家文章的完整内容。 14 15 **参数:** 16 - `url` (必需): IT之家文章 URL,格式如 `https://www.ithome.com/0/663/928.htm` 17 - `format_summary` (可选): 是否生成可读的文本摘要,默认 false 18 19 **返回数据:** 20 - `success`: 是否成功提取 21 - `title`: 文章标题 22 - `description`: 文章摘要(meta description) 23 - `keywords`: 关键词标签 24 - `date`: 发布日期时间(格式:YYYY/MM/DD HH:MM:SS) 25 - `author`: 作者姓名 26 - `editor`: 责编姓名 27 - `source`: 来源(通常为"IT之家") 28 - `content`: 文章正文内容(纯文本) 29 - `images`: 图片列表,包含 URL、alt 文本、title 30 - `category_id`: 分类 ID(从 URL 提取) 31 - `article_id`: 文章 ID(从 URL 提取) 32 - `summary`: 格式化的摘要文本(当 format_summary=true 时) 33 34 **示例:** 35 ```python 36 result = await execute({ 37 'function': 'fetch_article', 38 'url': 'https://www.ithome.com/0/663/928.htm', 39 'format_summary': True 40 }) 41 ``` 42 43 ### fetch_articles 44 45 批量获取多篇文章,支持并发请求。 46 47 **参数:** 48 - `urls` (必需): IT之家文章 URL 列表 49 50 **返回数据:** 51 - `success`: 总体执行状态 52 - `total`: 总数量 53 - `successful`: 成功数量 54 - `failed`: 失败数量 55 - `articles`: 文章数据列表 56 57 **示例:** 58 ```python 59 result = await execute({ 60 'function': 'fetch_articles', 61 'urls': [ 62 'https://www.ithome.com/0/663/928.htm', 63 'https://www.ithome.com/0/521/657.htm' 64 ] 65 }) 66 ``` 67 68 ## URL 格式 69 70 IT之家文章 URL 格式为: 71 ``` 72 https://www.ithome.com/{category_id}/{article_id}.htm 73 ``` 74 75 例如: 76 - `https://www.ithome.com/0/663/928.htm` (category_id=663, article_id=928) 77 - `https://www.ithome.com/0/521/657.htm` (category_id=521, article_id=657) 78 79 ## 提取字段说明 80 81 | 字段 | 说明 | 示例值 | 82 |------|------|--------| 83 | title | 文章标题 | "2499 元起,小米 Redmi K60 发布:..." | 84 | date | 发布时间 | "2022/12/27 20:03:58" | 85 | author | 作者 | "汪淼" | 86 | editor | 责编 | "汪淼" | 87 | source | 来源 | "IT之家" | 88 | keywords | 关键词 | "Redmi K60" | 89 | content | 正文内容 | 完整文章内容(纯文本) | 90 | images | 图片列表 | [{"url": "...", "alt": ""}] | 91 92 ## 技术实现 93 94 - 使用 aiohttp 进行异步 HTTP 请求 95 - 使用 BeautifulSoup 进行 HTML 解析 96 - 提取 `<h1>` 标签作为标题 97 - 提取 `#paragraph` 元素作为正文内容 98 - 通过特定的 span ID(pubtime_baidu, author_baidu, editor_baidu)提取元数据 99 - 支持 lazy-load 图片(data-original 属性) 100 101 ## 错误处理 102 103 - 无效域名返回错误信息 104 - URL 格式不正确返回错误信息 105 - HTTP 错误(如 404, 500)返回状态码 106 - 网络超时返回超时错误 107 - 所有错误不会抛出异常,而是返回包含 `success: false` 和 `error` 字段的结果 108 109 ## 注意事项 110 111 - 内容提取为纯文本,会移除 HTML 标签 112 - 图片 URL 会自动转换为绝对路径 113 - 部分文章可能缺少某些元数据字段(作者、责编等) 114 - 正文内容包含完整的 \n 分隔符
antins-labs/searchos/tree/main/searchos/skills/library/access/www_ithome_com commit 166895a3b3
Frequently asked questions How do I install the Www Ithome Com skill? Run npx skillmds@latest add antins-labs/www-ithome-com in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Www Ithome Com skill do? IT之家文章提取器 It is listed under Coding & Dev Tools on SkillMD.
Is Www Ithome Com safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Www Ithome Com? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Www Ithome Com free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Www Ithome Com? antins-labs (@antins-labs) published this skill. Their other Agent Skills are listed on their SkillMD profile.