返回顶部
s

save-article-with-images保存图文文章

>

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.1
安全检测
已通过
102
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

save-article-with-images

保存带图片的文章

将网页文章保存到本地存储,支持带图片的文章。自动下载图片、生成Markdown并转换为PDF。

触发词

  • - 保存文章
  • 保存这篇文章
  • 下载文章
  • 剪藏文章

快速执行

无图片文章

  1. 1. 获取文章内容(Jina Reader或浏览器)
  2. 保存到 saved-articles/{标题}-{日期}.md
  3. 发送文件到飞书

带图片文章

  1. 1. 创建目录 reports/{文章名称}/
  2. 创建 images/ 子目录
  3. 下载所有图片到 images/
  4. 生成 Markdown(相对路径引用)
  5. 转换为 PDF
  6. 发送 PDF 到飞书

完整工作流程

步骤 1:检查文章是否包含图片

方法

  • - Jina Reader 返回的内容包含 Image 格式
  • 或原始网页包含 标签

决策

  • - 图片 < 3 → 直接保存 Markdown,不单独下载图片
  • 图片 ≥ 3 → 使用图片工作流程处理



步骤 2:创建目录结构

bash
mkdir -p ~/.openclaw/workspace/reports/{文章名称}/images/

目录结构

reports/{文章名称}/
├── {文章名称}.md # Markdown 文件
├── {文章名称}.html # HTML 中间文件(可选)
├── {文章名称}.pdf # 最终输出(可选)
└── images/ # 图片目录
├── image1.jpg
├── image2.png
└── ...



步骤 3:获取文章内容

方法 A:Jina Reader(推荐)

bash
curl -s https://r.jina.ai/URL

优点:自动转换为 Markdown,提取图片链接
缺点:部分网站被屏蔽

方法 B:浏览器获取

bash

打开网页


browser action=open url=URL

获取内容

browser action=act kind=evaluate fn=() => document.body.innerText

获取图片

browser action=act kind=evaluate fn=() => { const imgs = document.querySelectorAll(img); return JSON.stringify(Array.from(imgs).map(img => ({ src: img.src, alt: img.alt }))); }

步骤 4:下载图片

单张图片

bash
curl -o images/image1.jpg https://example.com/image.jpg

批量下载(Python)

python
import requests
from pathlib import Path

def downloadimages(imageurls, output_dir):
下载图片列表
outputdir = Path(outputdir)
outputdir.mkdir(parents=True, existok=True)

for i, url in enumerate(image_urls, 1):
try:
# 获取扩展名
ext = url.split(.)[-1].split(?)[0]
if ext not in [jpg, jpeg, png, gif, webp]:
ext = jpg

# 下载
resp = requests.get(url, timeout=30, headers={
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
})

if resp.status_code == 200:
filename = fimage{i}.{ext}
(outputdir / filename).writebytes(resp.content)
print(f✅ {filename})
else:
print(f❌ HTTP {resp.status_code}: {url})
except Exception as e:
print(f❌ {e}: {url})

使用方式

download_images([url1, url2], images/)

图片命名

  • - 顺序命名:image1.jpg、image2.png、...
  • 按内容命名:cover.jpg、screenshot.png、...



步骤 5:生成 Markdown

模板

markdown

{文章标题}

来源:{URL}
作者:{作者}
发布时间:{日期}


封面

{内容}



图片

图 1:{描述}
图 2:{描述}



保存时间:{时间戳}

图片引用格式
markdown
描述



步骤 6:转换为 PDF(可选)

使用预设样式

bash

CSS 文件


CSS_FILE=~/.openclaw/workspace/templates/mobile-friendly.css

转换为 HTML

pandoc {文章名称}.md -o {文章名称}.html --standalone --css=$CSS_FILE

生成 PDF

weasyprint {文章名称}.html {文章名称}.pdf

PDF 配置

  • - 正文:16pt,行高 1.8
  • 页面:6×9 英寸,页边距 1.5cm
  • 字体:Noto Sans CJK SC

⚠️ 图片溢出解决方案(重要)

问题:图片过大(如 1200px 宽),超出 PDF 页面宽度(约 432pt/6 英寸)

解决方案:创建 CSS 文件限制图片最大宽度

所需 CSS
css
/ 防止图片溢出 /
img {
max-width: 100%;
height: auto;
display: block;
margin: 1em auto;
}

/ images/ 目录下的图片 - 90% 宽度 /
img[src^=images/] {
max-width: 90%;
margin: 0.5em auto;
}

/ 正文样式 /
body {
max-width: 100%;
padding: 1cm;
}

正确的 PDF 生成流程
bash

1. 创建 CSS 文件(在文章目录中)


cat > style.css << EOF
img { max-width: 100%; height: auto; }
img[src^=images/] { max-width: 90%; }
EOF

2. 使用 CSS 生成 HTML

pandoc {文章名称}.md -o {文章名称}.html --standalone --css=style.css

3. 生成 PDF

weasyprint {文章名称}.html {文章名称}.pdf

关键点

  • - ✅ 必须添加 max-width: 100% 或 max-width: 90%
  • ✅ 使用相对路径 images/xxx.jpg
  • ❌ 不要按原始尺寸渲染图片(会溢出)



步骤 7:发送到飞书

发送 Markdown

message action=send channel=feishu target=user:ou_xxx filePath=path/to/file.md

发送 PDF

message action=send channel=feishu target=user:ou_xxx filePath=path/to/file.pdf



平台特定处理


来源获取方法图片处理
Twitter/XJina Reader下载 pbs.twimg.com 图片
微信公众号
browser + Camoufox | 下载 mmbiz.qpic.cn 图片 |
| 普通网页 | Jina Reader | 下载所有 img 标签 |
| 需要登录的网站 | browser | 用户手动截图 |


Twitter/X 文章

图片 URL 格式

https://pbs.twimg.com/media/XXXXX?format=jpg&name=small

下载命令
bash

获取最佳质量


curl -o images/image1.jpg https://pbs.twimg.com/media/XXXXX?format=jpg&name=large


微信公众号文章

问题:微信有防盗链,直接下载失败

解决方案

  1. 1. 使用浏览器打开文章
  2. 保存截图
  3. 或使用 Camoufox 工具

bash

使用 agent-reach 工具


cd ~/.agent-reach/tools/wechat-article-for-ai
python3 main.py https://mp.weixin.qq.com/s/ARTICLE_ID


检查清单

保存后,验证:

□ Markdown 文件已生成
□ 所有图片下载成功
□ 图片相对路径正确
□ 图片显示正常(本地预览)
□ PDF 生成成功(可选)
□ 文件已发送到飞书



错误处理


错误原因解决方案
图片下载失败防盗链/网络问题使用浏览器或降低质量
PDF 生成失败
缺少字体/依赖 | 检查 weasyprint

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 save-article-with-images-1776027169 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 save-article-with-images-1776027169 技能

通过命令行安装

skillhub install save-article-with-images-1776027169

下载

⬇ 下载 save-article-with-images v1.0.1(免费)

文件大小: 6.9 KB | 发布时间: 2026-4-13 11:52

v1.0.1 最新 2026-4-13 11:52
Version 1.0.1

- Added _meta.json and scripts/save_wechat.py files for WeChat Official Account article support.
- Updated documentation (SKILL.md) to include WeChat-specific workflows, troubleshooting, and error handling.
- Enhanced platform compatibility by supporting isolation/subagent usage for WeChat articles.
- Added checklist and improved instructions for image downloading, Markdown generation, and PDF conversion.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部