You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

39 lines
1.1 KiB

#!/usr/bin/env python3
"""
截图百度首页
"""
import asyncio
from playwright.async_api import async_playwright
import os
async def main():
output_path = "/root/.openclaw/workspace/code-generate/baidu_screenshot.png"
print("正在启动浏览器...")
async with async_playwright() as p:
print("正在启动 Chromium...")
browser = await p.chromium.launch(
headless=True,
args=[
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage"
]
)
print("正在打开新页面...")
page = await browser.new_page()
print("正在访问百度首页...")
await page.goto("https://www.baidu.com", wait_until="networkidle", timeout=30000)
print("正在截图...")
await page.screenshot(path=output_path, full_page=False)
print(f"✅ 截图已保存到: {output_path}")
await browser.close()
if __name__ == "__main__":
asyncio.run(main())