python playwright 不自动关闭浏览器
时间: 2023-10-10 16:08:56 浏览: 574
python实现浏览器自动化
当使用 python playwright 完成网页自动化任务后,浏览器通常会自动关闭,如果需要保持浏览器窗口打开,可以在启动时添加参数 headless=False,例如:
```python
from playwright.sync_api import Playwright, sync_playwright
with sync_playwright() as playwright:
browser = playwright.chromium.launch(headless=False)
page = browser.new_page()
# 执行自动化任务
browser.close()
```
这样,执行完成后浏览器窗口就会一直保持打开状态。
阅读全文