xiaohongshu
xiaohongshu
feishu-sync
使用Playwright自动同步文档到飞书。Use for tasks like syncing markdown to Feishu, automating Feishu document updates, browser automation for Feishu. Keywords: 飞书同步, feishu sync, playwright, 文档同步, 自动化
Full skill instructions
使用Playwright自动化同步Markdown文档到飞书Wiki/文档
Use this skill for 飞书文档自动同步、Markdown到飞书的自动化、浏览器自动化操作飞书。
# 确保使用anaconda python(已安装playwright)
/opt/anaconda3/bin/python3 -c "from playwright.sync_api import sync_playwright; print('OK')"
# 如未安装,执行:
pip install playwright pyperclip
playwright install chromium
/opt/anaconda3/bin/python3 scripts/sync_to_feishu.py
位置: scripts/sync_to_feishu.py
# 目标飞书文档URL
FEISHU_URL = "https://xxx.feishu.cn/wiki/xxxxxxx"
# 源文件路径
REPORT_PATH = Path("docs/research/your-report.md")
1. 读取本地Markdown文件
2. 复制内容到系统剪贴板
3. 启动Chrome浏览器(非无头模式)
4. 导航到飞书文档
5. 检测登录状态,等待用户登录(5分钟超时)
6. 登录后自动点击编辑区域
7. 移动到文档末尾,添加分隔线
8. 自动粘贴内容(Cmd+V)
9. 等待用户确认后关闭浏览器
# 推荐:使用系统安装的Chrome,避免下载超时
browser = await p.chromium.launch(
headless=False,
channel="chrome" # 关键参数
)
原因: Chromium下载经常超时(30s),使用系统Chrome可跳过下载步骤。
# 在脚本开头添加,确保实时输出
sys.stdout.reconfigure(line_buffering=True)
sys.stderr.reconfigure(line_buffering=True)
原因: 后台运行时输出会被缓冲,无法实时监控进度。
await page.wait_for_url(
lambda url: "wiki" in url and "accounts" not in url,
timeout=300000 # 5分钟,给用户足够时间扫码登录
)
原因: 扫码登录需要时间,2分钟可能不够。
editor_selectors = [
'[data-testid="doc-editor"]',
'.doc-content',
'.suite-markdown-container',
'[contenteditable="true"]', # 最通用
'.editor-container',
'.wiki-content',
'.lark-editor',
]
原因: 飞书不同版本/页面的编辑器选择器可能不同。
import pyperclip
pyperclip.copy(report_content)
# 然后用键盘快捷键粘贴
await page.keyboard.press('Meta+v')
原因: 直接用Playwright的fill()方法对富文本编辑器兼容性差。
Error: Request to https://cdn.playwright.dev/... timed out after 30000ms
解决: 使用 channel="chrome" 参数使用系统Chrome。
❌ 登录超时或失败: Timeout 120000ms exceeded
解决:
⚠️ 未找到编辑区域,尝试点击页面中心...
解决:
解决:
解决: 添加 sys.stdout.reconfigure(line_buffering=True)
FEISHU_URLS = [
"https://xxx.feishu.cn/wiki/doc1",
"https://xxx.feishu.cn/wiki/doc2",
]
for url in FEISHU_URLS:
await sync_to_document(page, url, content)
# crontab -e
0 9 * * * /opt/anaconda3/bin/python3 /path/to/sync_to_feishu.py >> /var/log/feishu-sync.log 2>&1
# 全选后粘贴,替换全部内容
await page.keyboard.press('Meta+a')
await page.keyboard.press('Meta+v')
#!/opt/anaconda3/bin/python3
"""飞书文档自动同步"""
import asyncio
import sys
from pathlib import Path
sys.stdout.reconfigure(line_buffering=True)
sys.stderr.reconfigure(line_buffering=True)
from playwright.async_api import async_playwright
import pyperclip
FEISHU_URL = "https://xxx.feishu.cn/wiki/xxx"
SOURCE_FILE = Path("docs/your-file.md")
async def sync():
content = SOURCE_FILE.read_text(encoding="utf-8")
pyperclip.copy(content)
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False, channel="chrome")
page = await (await browser.new_context()).new_page()
await page.goto(FEISHU_URL)
await page.wait_for_timeout(3000)
# 等待登录
if "accounts" in page.url:
print("请登录飞书...")
await page.wait_for_url(
lambda u: "wiki" in u and "accounts" not in u,
timeout=300000
)
# 点击编辑区域
await page.wait_for_timeout(3000)
await page.click('[contenteditable="true"]', timeout=5000)
# 粘贴
await page.keyboard.press('Meta+End')
await page.keyboard.press('Enter')
await page.keyboard.press('Meta+v')
print("✅ 同步完成")
await page.wait_for_event('close', timeout=300000)
await browser.close()
if __name__ == "__main__":
asyncio.run(sync())
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience