Browser automation
Use the proxy with Playwright
Playwright takes the proxy straight at browser launch, credentials included. It's the easiest way to automate a browser through an authenticated proxy.
Step by step
- 1
Set the proxy protocol to HTTP in the client area: Chromium doesn't support username/password authentication on SOCKS5 proxies.
- 2
Pass server, username and password in the proxy option of chromium.launch() (or browser.newContext() to use a different proxy per context).
- 3
Open an IP-check page to confirm traffic goes through the proxy.
- 4
For a new IP close the context, call the rotation link, wait about 20 seconds and open a new context.
JavaScript (Node.js)
import { chromium } from "playwright";
const browser = await chromium.launch({
proxy: { server: "http://HOST:PORT", username: "USER", password: "PASSWORD" },
});
const page = await browser.newPage();
await page.goto("https://api.ipify.org");
console.log(await page.textContent("body"));
await browser.close();
// Python: p.chromium.launch(proxy={"server": "http://HOST:PORT", "username": "USER", "password": "PASSWORD"})Replace USER, PASSWORD, HOST and PORT with your proxy's data (client area › proxy › Connection).
Tips
- With several contexts (browser.newContext({ proxy })) you can use different proxies in one browser, one per profile.
- Set the context's locale and timezoneId to match the proxy's country, e.g. it-IT and Europe/Rome.
- In the client area pick the TCP/IP fingerprint of the system your browser emulates (usually Windows or macOS).
- Playwright's Firefox and WebKit accept the same proxy options.
