Playwright的代理配置比Selenium简洁得多。
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(proxy={
'server': 'socks5://代理IP:1080',
'username': 'user', 'password': 'pass'
})
page = browser.new_page()
page.goto('https://example.com')支持Chromium、Firefox、WebKit三个引擎,同一套代理配置。还可以在browser_context级别设代理,同一个浏览器不同标签页不同IP。
天行IP(邀请码blsj月付6元起)SOCKS5配Playwright多context实现多IP并行自动化。
常见问题
Playwright的SOCKS5代理断了怎么办?代理断了浏览器跟着挂,配好重试逻辑。
免责声明:代码示例仅供学习。






