Install
openclaw skills install @cgxxxxxxxxxxxx/young-post-downloaderopenclaw skills install @cgxxxxxxxxxxxx/young-post-downloader自动化下载 Young Post Club Spark 网站的「Today's Read」文章,生成精美排版的 PDF 文档并上传到飞书云空间。
当用户要求:
触发此技能。
1. 访问 Spark 页面 → 2. 解析文章列表 → 3. 批量下载 → 4. 生成 HTML → 5. 转换 PDF → 6. 上传飞书
python scripts/download_articles.py
python scripts/download_articles.py \
--url "https://www.youngpostclub.com/spark" \
--output-dir "/path/to/workspace" \
--upload-to-feishu true
使用 web_fetch 工具获取 Spark 主页内容:
web_fetch(url="https://www.youngpostclub.com/spark", extractMode="markdown")
从页面提取所有文章链接,识别模式:
/yp/news/... - 新闻类/spark/learning-zone/... - 学习区/yp/being-well/... - 健康生活/spark/share-us/... - 读者投稿对每篇文章调用 web_fetch:
for article_url in article_urls:
content = web_fetch(url=article_url, extractMode="markdown")
articles.append({
"title": content["title"],
"content": content["text"],
"url": article_url,
"date": extract_date(content)
})
创建带目录、样式排版的 HTML:
输出路径:{workspace}/young-post-spark-{date}.html
使用 Chrome 无头模式:
google-chrome --headless --disable-gpu \
--print-to-pdf={output}.pdf \
--print-to-pdf-no-header \
--paper-size=A4 \
{input}.html
使用 feishu_drive_file 上传:
feishu_drive_file(
action="upload",
file_path=pdf_path,
file_name=f"Young Post Spark 文章合集 - {date}.pdf",
size=file_size
)
| 文件 | 说明 | 大小 |
|---|---|---|
young-post-spark-{date}.html | HTML 版本,可用 Word 打开 | ~40 KB |
young-post-spark-{date}.pdf | PDF 版本,A4 打印优化 | ~300 KB |
网页加载失败
web_fetchPDF 转换失败
which google-chrome飞书上传失败
编辑脚本中的 WORKSPACE 变量:
WORKSPACE = "/your/custom/path"
只下载特定类别的文章:
CATEGORIES = ["news", "learning-zone"] # 只下载这些类别
修改 HTML 中的 CSS:
body {
font-family: "Calibri", "Arial", sans-serif;
font-size: 11pt;
line-height: 1.6;
}
用户:「下载 Young Post Spark 今天的文章」
1. 访问 spark 页面
2. 解析 17 篇文章
3. 批量下载
4. 生成 HTML + PDF
5. 上传飞书
→ 回复:✅ 已下载 17 篇文章并上传到飞书云空间
用户:「把 Young Post 的文章转成 PDF」
跳过 HTML 预览,直接生成 PDF
→ 回复:📄 PDF 已生成并上传
用户:「只下载学习区的文章」
过滤 URL 包含 learning-zone 的文章
→ 回复:📚 已下载 5 篇学习区文章