Browser automation
Use the proxy with Puppeteer
In Puppeteer the proxy is passed to Chrome with the --proxy-server argument, while the username and password are provided per page with page.authenticate().
Step by step
- 1
Set the proxy protocol to HTTP in the client area: Chrome doesn't support authentication on SOCKS5 proxies.
- 2
Launch the browser with --proxy-server=http://HOST:PORT (no credentials in the address).
- 3
On every new page call page.authenticate() with username and password before page.goto().
- 4
To change IP, call the rotation link, wait about 20 seconds and carry on browsing.
JavaScript (Node.js)
import puppeteer from "puppeteer";
const browser = await puppeteer.launch({ args: ["--proxy-server=http://HOST:PORT"] });
const page = await browser.newPage();
await page.authenticate({ username: "USER", password: "PASSWORD" });
await page.goto("https://api.ipify.org");
console.log(await page.$eval("body", (b) => b.textContent));
await browser.close();Replace USER, PASSWORD, HOST and PORT with your proxy's data (client area › proxy › Connection).
Tips
- page.authenticate() applies to a single page: call it on every new tab.
- To use different proxies in one process, create separate contexts with browser.createBrowserContext({ proxyServer }).
- Align language and timezone with page.emulateTimezone() and the Accept-Language header.
- Don't put the username and password in --proxy-server: Chrome ignores them.
