x-article-fetcher
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 "x-article-fetcher" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-d6b2a2c88ac92848973dae76119a28ac753fd5da5e89086711ce8c083cd36ea5. Verify the upstream source and version against https://skillhub.cn/skills/user_760e259a/x-article-fetcher 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
Tool to fetch X (Twitter) longform articles/notes and export them to Markdown, preserving images in their original positions and supporting image download to local storage. Implements fetching via X's GraphQL API (TweetResultByRestId) without browser automation. Prerequisite: the user must copy auth_token and ct0 values from browser DevTools → Application → Cookies. Triggered when a user supplies an x.com article link or requests to fetch/export/save an X article or convert it to Markdown/local archive.
Introduction source: third_party · user_760e259a · 1.0.1 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Software, accounts and paid services
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: x-article-fetcher
version: 1.1.0
category: 效率工具
platforms: [win32, darwin, linux]
description: 抓取 X (Twitter) 长文章(article/note)输出为 Markdown,含图片嵌入原文正确位置、支持下载图片到本地。通过 X 的 GraphQL API(TweetResultByRestId)无需浏览器自动化。触发场景:(1) 用户提供 x.com 文章链接要求抓取/导出/保存,(2) 用户说"抓取 X 文章""导出 Twitter 文章""保存这篇 X 长文",(3) 用户想把 X 文章转 Markdown/本地存档。前置要求:用户必须从浏览器 DevTools → Application → Cookies 复制 auth_token 和 ct0 两个值。
agent_created: trueX Article Fetcher
通过 X.com 的 GraphQL API 抓取长文章(article),解析 Draft.js 内容模型,输出带图片的 Markdown 文件。
前置条件
用户必须提供 X 登录态的 auth_token 和 ct0 两个 cookie 值。引导用户按以下步骤获取:
- 在浏览器中打开 https://x.com(确保已登录)
- 按 F12 → Application(应用程序)→ Cookies → https://x.com
- 找到
auth_token,双击值列,Ctrl+C 复制 - 找到
ct0,双击值列,Ctrl+C 复制 - 将两个值告知(用于当次抓取,不存储)
⚠️ 这相当于临时借用用户登录态。抓取完成后提醒用户可以去 X 安全设置刷新 token。脚本通过命令行参数传入,不持久化凭证。
工作流
1. 确认文章 URL
从用户消息中提取 X 文章链接。支持的格式:
https://x.com/{user}/article/{id}https://x.com/i/article/{id}
提取 tweet/article ID(末尾数字)。
2. 获取凭证
如果用户尚未提供 auth_token 和 ct0,引导用户按上述步骤获取。
3. 运行脚本
执行 scripts/fetch_x_article.py,传入文章 URL 和 cookie 值:
python scripts/fetch_x_article.py "<article_url>" \
--auth-token "<token>" --ct0 "<ct0>"
可选项:
--download-images:下载图片到本地./images/目录--output <path>:指定输出文件路径(默认./article.md)
4. 呈现结果
脚本输出:
article.md:带图片嵌入的完整 Markdown 文件- 若开启
--download-images,还会生成images/目录(含所有图片原始文件)和gallery.html(图片浏览页)
加载 present_files 将 article.md 呈现给用户。
5. (可选) 自动生成 PDF
如需将文章转为精美 PDF(含封面、目录、分页、图片原位嵌入),执行:
python scripts/x_article_to_pdf.py --dir <article_dir>
其中 <article_dir> 是包含 article.md 和 images/ 目录的文章文件夹。脚本将:
- 读取 frontmatter 中的
title:作为 PDF 标题 - 自动生成深蓝渐变封面 + 目录页
- 用 Edge headless 模式渲染 A4 PDF,图片在原文位置
- 输出
article.pdf到文章目录
此脚本依赖 markdown、pygments 和本机 Edge 浏览器。
依赖
抓取
- Python 3.7+,
requests库
PDF 生成(可选)
- Python 3.7+,
markdown、pygments库 - Microsoft Edge 浏览器(Windows 自带)
技术细节
脚本内部流程:
- 从 x.com 主页动态提取最新的
TweetResultByRestIdqueryId(正则匹配main.xxx.js) - 构造 GraphQL GET 请求,携带变量(tweetId, features, fieldToggles)和认证 headers
- 解析响应中的 Draft.js
content_state:- blocks → 按 type 渲染(header/code/ordered-list/unstyled)
- inlineStyleRanges → Markdown 粗体/斜体
- entityRanges → 链接(LINK)+ 图片(MEDIA/IMAGE)
- 通过
media_entities数组建立 mediaId → 图片 URL 映射 - 将图片
嵌入原文正确的 block 位置 - (可选)下载所有图片到本地
Current listing version
1.0.1
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决 X 长文章抓取转 Markdown 的实际存档需求
- 支持图片嵌入原文位置及本地下载,功能完整
Highlights
- 触发场景描述清晰,覆盖多种用户表达方式
- 关键词边界明确,不易误触
Areas to improve
-
缺少明确的出口条件说明 Reported severity: Minor
工作流中未说明任务完成后的明确出口或结束状态
Recommendation: 在步骤 4 或 5 后增加'任务完成,可查看生成的 Markdown/PDF 文件'等出口说明
Highlights
- Phase 划分清晰,含端到端示例
- frontmatter 完整,文档结构良好
Areas to improve
-
主要异常未处理 Reported severity: Major
未覆盖网络错误、API 变更、cookie 失效、图片下载失败等关键异常场景
Recommendation: 在脚本中添加异常处理逻辑,并向用户提供明确的错误提示和重试建议
-
不可逆操作无确认机制 Reported severity: Major
下载图片到本地属于不可逆操作,但未要求用户确认
Recommendation: 在执行 --download-images 前增加确认提示,避免误操作
Highlights
- 工具来源明确,参数设计合理
- 通过 GraphQL API 实现,无需浏览器自动化,技术方案可靠
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.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
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.
- x.com
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.