Skip to main content

How to use Proxy

Puppeteer & Bright Data / Luminati

An easy example of how to use proxy with auth

const puppeteer = require('puppeteer')
let proxyCountry = 'us'

async function run() {
try {
browser = await puppeteer.connect({
browserWSEndpoint:
'wss://chrome-us.browsercloud.io'+
'?token=BROWSERCLOUD_TOKEN'+
'&--proxy-server=http://zproxy.lum-superproxy.io:22225',
});

const page = await browser.newPage();
await page.authenticate({
username: 'lum-customer-CLIENT-zone-ZONENAME-country-' + proxyCountry,
password: 'PROXY_PASSWORD'
});

await page.goto('https://iplocation.com/');

await page.setViewport({ width: 1900, height: 1080 });
await page.screenshot({ path: `./image.jpeg` });
} catch (err) {
console.log(`❌ Error: ${err.message}`);
} finally {
await browser.close();
console.log(`🎉 Screenshots captured.`);
}
}

run();