Auto-sync: 2026-04-16 17:30

This commit is contained in:
2026-04-16 17:30:41 +08:00
parent b2250c60b2
commit c999498de4
662 changed files with 3797 additions and 21340 deletions

View File

@@ -1,38 +0,0 @@
---
title: Playwright
type: entity
tags: [浏览器自动化, 测试, 爬虫, 开源]
sources: ["https://playwright.dev"]
last_updated: 2026-04-15
---
## 基本信息
- **类型**Microsoft 开源浏览器自动化工具
- **官网**https://playwright.dev
- **支持语言**Python/Node.js/Java/C#
## 核心功能
- **多浏览器支持**Chromium/Firefox/WebKitWebKit 仅 macOS
- **无头模式**headless=True 默认,支持有头调试
- **自动等待**Actionability 检查(元素可见/可点击/attached 等)
- **截图/PDF**:整页截图和 PDF 生成
- **网络拦截**:监听/修改/屏蔽网络请求
- **移动端模拟**viewport 和 userAgent 定制
## 在 Wiki 中的角色
- [[可自动化可扩展AI增强的电商数据采集与处理系统]] 用于渲染 JS 动态页面
- [[Scrapy]] 通过 scrapy-playwright 插件集成,处理反爬或懒加载的电商页面
- Docker 环境mcr.microsoft.com/playwright/python:v1.48.0-jammy
- shm_size 需设置为 2gb 避免浏览器崩溃
## 关键参数
```python
PLAYWRIGHT_LAUNCH_OPTIONS = {
"headless": True,
"args": ["--no-sandbox", "--disable-setuid-sandbox"],
}
PLAYWRIGHT_CONTEXT_ARGS = {
"viewport": {"width": 1280, "height": 720},
}
```