Run Puppeteer through authenticated rotating proxies.
Run Puppeteer through authenticated rotating proxies. This example uses Rotating Proxies as the default gateway and can be adapted by replacing endpoint and routing credentials.
Install the client and create a file.
Use a clean project environment and pin tested dependency versions for production. The example target is a public scraping sandbox.
npm install puppeteerLoad proxy secrets from the environment.
The proxy username is not the LundProxy website login. Copy the complete username and password generated for the selected proxy product.
PROXY_USER=user-pool-crawlerPROXY_PASS=your-secretbrowser.mjs
Copy the code into the named file, set credentials, and run it from the project environment.
import puppeteer from "puppeteer";
const browser = await puppeteer.launch({
headless: true,
args: ["--proxy-server=http://proxy.lundproxy.com:36923"],
});
try {
const page = await browser.newPage();
await page.authenticate({
username: process.env.PROXY_USER,
password: process.env.PROXY_PASS,
});
await page.goto("https://quotes.toscrape.com/js/", {
waitUntil: "domcontentloaded",
timeout: 30_000,
});
console.log(await page.$$eval(".quote", nodes => nodes.length));
} finally {
await browser.close();
}
Keep the important behavior visible.
Add workload-specific controls before scale.
Test representative targets, response sizes, routing policy, concurrency, retries, validation, and completion window. Collect only public data you are authorized to access.
Puppeteer questions.
Does each page use a different exit?
That depends on the product and SESSION policy, not the number of Puppeteer pages.
Can I authenticate after navigation?
Authenticate before the first proxied navigation.
How should I reduce traffic?
Block only resources that are not required by the page behavior you need.