skills-vault/skills/clip-web-article/SKILL.md

96 lines
4.4 KiB
Markdown

---
name: clip-web-article
description: Use when the user wants to download or clip a single web article URL into lightweight local Markdown with local sibling images, especially requests like "下载文章 URL" for Zhihu answers/articles/pins, WeChat public account articles, X/Twitter posts or threads, and ordinary web articles. Uses OpenCLI browser/login state and never asks the user to paste cookies.
---
# Clip Web Article
Save one or more user-provided article URLs as discussion material. Each URL becomes one folder containing one Markdown file plus local image files.
## Default Output
Save to:
```text
C:\Users\wangq\Documents\Codex\knowledge-vault\sources\clipped-articles\文章参考
```
The default final shape is short enough for repeated daily use:
```text
YYYYMMDD-短标题/
短标题.md
img_1.jpg
img_2.png
```
Do not add platform folders, metadata JSON, logs, raw HTML, screenshots, YAML frontmatter, or original URL lines by default.
Callers may override the destination:
```powershell
conda run --no-capture-output -n skills-vault python -B .\scripts\clip_web_article.py "URL" --output-root "D:\target\folder"
```
## Procedure
1. Confirm the input is one or more article-like URLs.
2. Run the bundled script from this Skill directory:
```powershell
conda run --no-capture-output -n skills-vault python -B .\scripts\clip_web_article.py "URL"
```
3. For batch clipping, pass multiple URLs in one call:
```powershell
conda run --no-capture-output -n skills-vault python -B .\scripts\clip_web_article.py "URL1" "URL2" "URL3"
```
4. If running from another working directory, use the absolute script path:
```powershell
conda run --no-capture-output -n skills-vault python -B "C:\Users\wangq\.agents\skills\clip-web-article\scripts\clip_web_article.py" "URL"
```
5. If the script reports `Language: English`, keep the generated English Markdown as the original and create a sibling Chinese translation Markdown in the same folder. Preserve image links and code blocks. Do not replace the English original.
6. Report only the saved folder, Markdown file name(s), image count, and any short failure/partial-success note.
## Routing
The script uses OpenCLI as the browser and extraction substrate:
- `mp.weixin.qq.com`: `opencli weixin download`, then flatten output.
- `zhuanlan.zhihu.com`: `opencli zhihu download`, then flatten output.
- `www.zhihu.com/question/.../answer/...`: `opencli zhihu answer-detail <answer-id>`, so only the target answer is saved.
- `www.zhihu.com/pin/...`: `opencli web read`, then remove Zhihu page chrome, author cards, edit/comment UI, and keep the pin body plus body images.
- `x.com` / `twitter.com`: `opencli twitter thread`, then save only the target status row and localize its media.
- Other URLs: `opencli web read`, then flatten output.
All OpenCLI browser-backed commands pass `--keep-tab false` so the tab lease opened for clipping is released after the command. Do not close the user's Chrome process.
## Boundaries
- Use the user's connected OpenCLI Browser Bridge / logged-in browser state when needed.
- Do not read or save raw cookies, localStorage, passwords, session stores, or tokens.
- Do not ask the user to paste cookies.
- Do not bypass CAPTCHA, verification gates, paywalls, DRM, anti-bot restrictions, or login walls.
- Do not perform side-effect actions such as posting, liking, following, commenting, collecting, or sending messages.
- Do not batch crawl feeds or accounts.
- Save only the original article/post/answer body. Do not include comments, reply threads, other Zhihu answers, recommendation cards, profile cards, or page operation UI.
- For discussion-like URLs, treat the URL target as the boundary: a Zhihu answer URL means that answer only; an X status URL means that status only.
- If OpenCLI reports auth, verification, bridge, timeout, or blocked access, stop and ask the user to open the page in a connected browser or provide the content manually.
## Translation
For any English article/post from any source, preserve the English original Markdown and create a separate Chinese translation Markdown in the same folder. Do not append the translation into the original file and do not overwrite the original.
## Validation
For source changes, run:
```powershell
conda run -n skills-vault python -B -m unittest discover -s skills\clip-web-article\tests -v
conda run -n skills-vault python -B scripts\quick_validate.py skills\clip-web-article
```