How to use SOCKS5 proxy in Pyppeteer
Configuring Pyppeteer to use a SOCKS5 proxy is as easy as passing the args
option to launch()
:
browser = await launch({
"args": ['--proxy-server=socks5://localhost:8000'],
})
Full example
#!/usr/bin/env python3
import asyncio
from pyppeteer import launch
async def main():
browser = await launch({
"args": ['--proxy-server=socks5://localhost:8000'],
})
page = await browser.newPage()
await page.goto('https://www.techoverflow.net', {'waitUntil': 'networkidle2'})
# Make screenshot
await page.screenshot({'path': 'screenshot.png'})
# Cleanup
await browser.close()
asyncio.get_event_loop().run_until_complete(main())