Proxies
Route browser traffic through proxies to change IP addresses. You can:
Use Hyperbrowser's proxy pool
Bring your own proxies
To enable these proxy configurations, you can set them in the session creation params.
import { connect } from "puppeteer-core";
import { Hyperbrowser } from "@hyperbrowser/sdk";
import { config } from "dotenv";
config();
const client = new Hyperbrowser({
apiKey: process.env.HYPERBROWSER_API_KEY,
});
const main = async () => {
const session = await client.sessions.create({
useProxy: true,
proxyCountry: "US",
// use own proxy
/**
* proxyServer: "http://...",
* proxyServerUsername: "...",
* proxyServerPassword: "...",
*/
});
try {
const browser = await connect({
browserWSEndpoint: session.wsEndpoint,
defaultViewport: null,
});
const [page] = await browser.pages();
// Navigate to a website
console.log("Navigating to Hacker News...");
await page.goto("https://news.ycombinator.com/");
const pageTitle = await page.title();
console.log("Page 1:", pageTitle);
await page.evaluate(() => {
console.log("Page 1:", document.title);
});
} catch (err) {
console.error(`Encountered error: ${err}`);
} finally {
await client.sessions.stop(session.id);
}
};
main();
Geospecific Proxies
Hyperbrowser supports geo-specific IPs as well. The specificity can range from country level down to city level. This can be specified by
...
await client.sessions.create({
useProxy: true,
proxyCountry: "US",
// or proxyCity: "New York"
});
...
Custom Proxies
If you want to use your own proxy service/providers, you can do so by specifying the following parameters when creating a session. If you use your own proxy provider, you will not be billed for any proxy usage.
...
await client.sessions.create({
useProxy: true,
proxyServer: "scheme://subdomain.proxyprovider.io:10000",
proxyServerUsername: "proxy-username",
proxyServerPassword: "proxy-password",
});
...
Last updated