Skip to main content

How to use Proxy with BrowserCloud

Using BrowserCloud built-in proxy servers

Add parameter &--proxy-server=browsercloud-proxies to browserWSEndpoint string to use built-in proxies

const puppeteer = require('puppeteer-extra')
const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin())

const API_TOKEN = "MY-TOKEN" // your token from the account

run('https://dnschecker.org/ip-location.php');

async function run(url) {
let browser = null;
let t1=Date.now();

try {
browser = await puppeteer.connect({
browserWSEndpoint:
`wss://chrome.browsercloud.io?token=${API_TOKEN}`+
'&--proxy-server=browsercloud-proxies',
});

const page = await browser.newPage();
await page.setExtraHTTPHeaders({
'browsercloud_token': API_TOKEN,
'browsercloud_proxy': 'datacenter', // available values: datacenter, residential, isp
'browsercloud_country': 'US' // country parameter is available for `datacenter` and `isp` proxy pools
});

await page.setViewport({ width: 1900, height: 1080 })
await page.goto(url, {'waitUntil' : 'domcontentloaded'});
await page.screenshot({ path: 'screenshot.png', fullPage: true });

await browser.close()
console.log(`Screenshot captured.`);
console.log((Date.now()-t1)/1000);
} catch (err) {
console.log(`❌ Error: ${err.message}`);
} finally {
await browser.close();
}
}

Proxy cost

info

Our proxy gate tries to use proxy traffic for crucial data only.

Static files like Images/JS/CSS/Fonts/etc are downloaded directly (without proxy) to make the most effective proxy cost

Proxy TypeDescriptionPrice / MB
datacenterFast rotating datacenter proxies.5 credits
residentialResidential ranges of IPs (request from real computers)110 credits
ispOrganizations' IP ranges. Low detection as a bot, speed faster than residential proxies140 credtits

Puppeteer & Bright Data / Luminati

info

Puppeteer & BrightData / Luminati

Please note that many proxies only support Chromium revisions in less than puppeteer 1.18.0. This is due to Chromium dropping support for Proxy-Authorization headers. Check your proxies documentation for how to properly authenticate, and ensure that you don't need to set a Proxy-Authorization header.

Add --proxy-server=https://my-proxy.com to endpoint URL to use your proxies for any framework

const puppeteer = require('puppeteer')

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

const page = await browser.newPage();
await page.authenticate({
username: 'PROXY_LOGIN',
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();