01Launch Chrome through the gateway
import puppeteer from "puppeteer";
const browser = await puppeteer.launch({
args: ["--proxy-server=http://gw.fullstackproxy.com:47631"],
});
const page = await browser.newPage();
await page.authenticate({ username: "USERNAME-country-us", password: "PASSWORD" });
await page.goto("https://api.ipify.org");
console.log(await page.evaluate(() => document.body.innerText));
await browser.close();Call page.authenticate on every new page, before its first goto. Without it Chrome gets a 407 from the gateway and the page fails to load.
02Keep one IP for the browser
A browser opens many connections for one page: the HTML, scripts, images, API calls. On a rotating login each of them can leave from a different IP, which looks odd to the site. For anything more than a single fetch, give the browser a session so everything shares one exit, held for up to 24 hours.
const session = "pp" + Date.now().toString(36);
await page.authenticate({
username: `USERNAME-country-us-session-${session}-lifetime-30`,
password: "PASSWORD",
});For a fresh IP, start a new session name. For an address that never changes, use an ISP proxy: put its own host and port in --proxy-server.
03Block heavy files to save GB
Residential and datacenter traffic is billed per GB, and images, fonts and video are most of a page. If you only need the text, do not download them:
await page.setRequestInterception(true);
page.on("request", (req) => {
if (["image", "media", "font"].includes(req.resourceType())) req.abort();
else req.continue();
});More ways to cut traffic are in how to use less proxy bandwidth.