ima-links
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "ima-links" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-18c32b3c6fe632fd564da19a644c2ed57149f3ff95899de993baa1d796ccce28. Verify the upstream source and version against https://skillhub.cn/skills/user_4c9c5ac8/ima-links before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Bulk-extract article links from specific sections of websites for export or import into IMA knowledge base. Helps users harvest all article URLs from a given site section on websites using a “list page + detail page” structure (e.g., government portals, news sites, document sites), exporting them as a list or importing them into Tencent IMA knowledge bases (personal or subscribed).
Introduction source: third_party · user_4c9c5ac8 · 1.0.1 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Translation pending; see source documentation.
- Software, accounts and paid services
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: ima-links
slug: ima-links
displayName: ima链接
agent_created: true
description: 帮助用户从任意网站的某个栏目或板块批量提取全部文章网页链接,导出为清单或一键导入腾讯 ima 知识库(个人库或订阅库)。适用于政府门户、新闻站、文档站等具有"列表页 + 详情页"结构的站点。ima链接
Overview
把"搜索/定位一个网站 → 针对某一个板块提取全部文章链接 → 导出清单或导入 ima 知识库"的整套流程固化下来。脚本自动处理不同站点的 HTML 差异(单/双引号 href、<ul><li><a> 与 <table><h4><a> 等不同列表结构、同页多板块的 catId 区分、分页),并复用 ima-skills 的 API 客户端完成导入。
适用:政府门户、新闻站、文档站、公众号归档等"列表页 + 详情页"结构的站点。
When to use
- 用户要给某个网站的某一个栏目/板块批量提取文章链接。
- 提取后要把这些链接导出成清单文件,或批量导入腾讯 ima 知识库(个人库或订阅库)。
- 不要用于:直接抓微信公众号文章正文(会被反爬拦截,见"踩坑备忘")。
依赖
- Python 3(提取脚本仅用标准库,无需 pip)。
- 导入 ima 需已安装
ima-skills技能(提供ima_api.cjs)并配置凭证(~/.config/ima/client_id+api_key,或环境变量IMA_CLIENT_ID/IMA_API_KEY)。
工作流
第 1 步:定位板块列表页
若用户只给了网站首页或父栏目,先用 WebSearch / WebFetch 找到目标板块的文章列表页 URL。通常是 .../xxx/index.html 这种专门列表页,而不是带摘要混排的首页。
关键:很多站点首页/栏目首页每个板块只列 4 篇左右,需要进入每个板块各自的完整列表页才能拿到全部文章。参考
references/gjbmj-example.md。
第 2 步:提取链接
运行 scripts/extract_links.py:
python3 scripts/extract_links.py "<板块列表页URL>" \
--output links.tsv \
[--base https://example.com] \
[--pattern "c409088"] \ # URL 必须匹配的正则(按板块/catId 过滤)
[--exclude "index"] \ # URL 必须不匹配的正则
[--paginate] [--page-template "index_{n}.html"] # 自动翻页
要点(详见脚本 docstring 与 gjbmj 案例):
- 引号兼容:同时匹配
href='...'与href="..."。 - 结构兼容:
<ul><li><a>、<table><h4><a>、带<em>的链接都能提取,标题自动去标签、合并空白。 - 按板块过滤:同页混入多板块时用
--pattern传 catId/路径片段(如 gjbmj 的c409088);跨两个 catId 的板块用正则c40909[01]。 - 相对链接:自动拼成绝对链接,仅保留同域。
- 输出:终端打印编号清单 + 写入 TSV(
标题\t链接)。
第 3 步(可选):导入 ima 知识库
运行 scripts/import_to_ima.cjs:
node scripts/import_to_ima.cjs links.tsv \
--kb "政策文库" \
[--folder "法律法规"] \ # 可选:倒入指定子文件夹,缺省进根目录
[--dry-run] # 只解析知识库/根目录并预览批次,不真正导入
要点:
- 解析知识库:先
search_knowledge_base(覆盖"我加入的订阅库",返回kb_id/kb_name),找不到再回退get_addable_knowledge_base_list(个人库,返回id/name)。 - 根目录 folder_id ≠ 知识库 ID:尤其订阅库。
import_urls的folder_id必须取自get_knowledge_list返回的根目录 folder_id(从current_path或条目parent_folder_id取得),不能用kb_id当 folder_id(否则报"文件夹不存在 222000")。 - 批量上限:
import_urls每次最多 10 个 URL,脚本自动分批;ima 按 URL 去重,重复导入安全。 - 成功判定:该接口顶层返回
code(非ret_code),code===0或msg==='success'即成功。
踩坑备忘
- 微信公众号:
mp.weixin.qq.com文章不可本地批量抓正文(触发"环境异常"验证页,多 UA/冷却/WebFetch 均无效)。但import_urls由 ima 服务端自动抓取,所以"提取链接 → 交给 ima 导入"是正确姿势。 - 首页不全:务必进入板块专属列表页拿全量文章。
- 同站多板块:用
--pattern按 catId/路径过滤,避免混入导航或兄弟板块链接。
使用示例
示例一:抓取中国网球协会「匹克球」栏目并导入「匹克球」知识库
目标:把 https://www.tennis.org.cn/events/pickleball/ 栏目下的全部文章链接,导入到 ima 的「匹克球」知识库(个人库)。
第 1 步 · 提取链接
该栏目只有 1 页、共 3 条真实文章(无分页)。页面里混有导航/栏目自身链接,用 --pattern 只保留真正的文章详情链接:
python3 scripts/extract_links.py "https://www.tennis.org.cn/events/pickleball/" \
--output links.tsv \
--base "https://www.tennis.org.cn" \
--pattern "events/pickleball/20"
提取结果(3 条):
- 中国匹克球巡回赛-「李宁杯」大连站(CPC-300、T500)在大连金普新区顺利举办
- 首届北京市高校匹克球社会指导员项目培训班举行
- 中国网球协会匹克球裁判员培训班、中国匹克球巡回赛(CPC-100、CPC-T125)在京顺利开展
第 2 步 · 导入 ima
先用 --dry-run 确认知识库能正确解析,再正式导入:
node scripts/import_to_ima.cjs links.tsv --kb "匹克球" --dry-run
node scripts/import_to_ima.cjs links.tsv --kb "匹克球"
导入结果:解析到「匹克球」个人库(根
folder_id=7406901457325695),1 批导入,成功 3 / 失败 0。
要点回顾
- 栏目页混有非文章链接时,靠
--pattern精确过滤,比"抓全页再人工筛"更稳。 - 个人库与订阅库都用
--kb 名称自动解析,无需手填 ID。
示例二:某政府门户多板块批量导入(订阅库)
更完整的"多板块 + 订阅库 + 分页"端到端案例见 references/gov-portal-example.md:从某政府门户网站的「通知公告 / 政策法规 / 政策解读 / 理论文章」等板块批量提取链接,并导入「政策文库」订阅库(管理员可写)。该案例覆盖了 --pattern 跨 catId 正则、index2.html 分页、订阅库根 folder_id ≠ kb_id 等关键坑。
Resources
scripts/extract_links.py:网页板块文章链接提取器(引号/结构兼容、catId 过滤、分页)。scripts/import_to_ima.cjs:复用ima-skills的ima_api.cjs,把链接清单批量导入 ima 知识库。references/gov-portal-example.md:某政府门户多板块提取 + 导入「政策文库」订阅库的真实端到端案例。references/pickleball-example.md:中国网球协会匹克球栏目抓取 + 导入「匹克球」个人库的真实端到端案例。
Current listing version
1.0.1
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决从网站栏目批量提取文章链接并导入知识库的实际需求
- 适用于政府门户、新闻站等具有明确结构的站点
- 提供端到端完整工作流和真实案例
Highlights
- 触发描述清晰完整,覆盖导出清单和导入知识库两种场景
- 明确排除不适用场景(微信公众号正文抓取)
- 边界定义清晰,避免误用
Highlights
- 文档结构完整,包含工作流、示例、踩坑备忘等关键章节
- 提供两个真实端到端案例,覆盖个人库和订阅库场景
- frontmatter 完整,格式规范
Highlights
- 工具依赖明确,参数说明详细
- 覆盖多种异常场景(分页、结构兼容、批量上限)
- 提供 --dry-run 机制确保导入安全
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 26
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- example.com
- www.tennis.org.cn
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Translation pending; see source documentation.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.