Files
Ubuntu 32b43f85bd a
2026-07-03 16:58:28 +08:00

26 lines
896 B
Python

#!/usr/bin/env python3
"""
用 Playwright 截图 personal-blog-architecture.html
"""
import asyncio
from playwright.async_api import async_playwright
async def main():
html_path = "/home/ubuntu/.nanobot/workspace/skills/hand-drawn-diagram/examples/personal-blog-architecture.html"
png_path = "/home/ubuntu/.nanobot/workspace/skills/hand-drawn-diagram/examples/personal-blog-architecture.png"
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page(
viewport={"width": 1800, "height": 1260}
)
await page.goto(f"file://{html_path}")
await page.wait_for_timeout(500)
# 截图整个 SVG
svg = await page.query_selector("svg")
await svg.screenshot(path=png_path)
print(f"✅ 截图已保存: {png_path}")
await browser.close()
asyncio.run(main())