Referral Program
Development

Playwright Proxy Setup

Scrape JavaScript-rendered pages through rotating proxies with Playwright.

Playwright automates Chromium, Firefox, and WebKit browsers - essential for scraping sites that render content with JavaScript. Configure SotaProxy at the browser launch level and every page the browser opens routes through the proxy.

Setup guide

1

Node.js - browser-level proxy

javascript
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({
    proxy: {
      server: 'http://proxy.sotaproxy.com:10000',
      username: 'YOUR_USERNAME',
      password: 'YOUR_PASSWORD',
    },
  });

  const page = await browser.newPage();
  await page.goto('https://httpbin.org/ip');
  const content = await page.content();
  console.log(content);
  await browser.close();
})();

Set the proxy at chromium.launch(). All pages created by this browser instance route through SotaProxy.

2

Python - browser-level proxy

python
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(
        proxy={
            "server": "http://proxy.sotaproxy.com:10000",
            "username": "YOUR_USERNAME",
            "password": "YOUR_PASSWORD",
        }
    )
    page = browser.new_page()
    page.goto("https://httpbin.org/ip")
    print(page.content())
    browser.close()

Same proxy configuration in Python. Works with sync_playwright and async_playwright.

3

Per-context proxy (different proxies per tab)

javascript
const browser = await chromium.launch();

// Each context gets its own proxy
const context1 = await browser.newContext({
  proxy: {
    server: 'http://proxy.sotaproxy.com:10000',
    username: 'YOUR_USERNAME_c_US',
    password: 'YOUR_PASSWORD',
  },
});

const context2 = await browser.newContext({
  proxy: {
    server: 'http://proxy.sotaproxy.com:10000',
    username: 'YOUR_USERNAME_c_DE',
    password: 'YOUR_PASSWORD',
  },
});

Launch one browser but create multiple contexts with different proxy configurations. Each context is isolated - useful for multi-region testing.

Automate it with the SotaProxy API

Everything above works without opening the dashboard. With an API key, Playwright can pull fresh proxy credentials, buy new proxies, and renew expiring ones - straight from code.

javascript
const API = 'https://api.sotaproxy.com/api/v1'
const H = { Authorization: 'Bearer sk_live_your_key' }

// Every active proxy on your account - no copy-pasting credentials
const { proxies } = await (await fetch(`${API}/proxies`, { headers: H })).json()
const p = proxies[0]
const proxyUrl = `http://${p.login}:${p.password}@${p.ip}:${p.portHttp}`

// Buy more when you scale (price-check first with POST /quote)
await fetch(`${API}/orders`, {
  method: 'POST',
  headers: { ...H, 'Content-Type': 'application/json', 'Idempotency-Key': 'my-unique-order-id' },
  body: JSON.stringify({ product: 'ipv4', countryId: 565, periodId: '1m', quantity: 5 }),
})
Read the API docs

Proxy at the browser or at the context

Playwright accepts credentials as separate fields rather than inside the URL. Context-level proxies are the feature that matters: every context can hold a different address in one browser process:

Rotating residential
login:password@proxy.sotaproxy.com:10000
Pinned to a country
login_c_US:password@proxy.sotaproxy.com:10000
Sticky for 15 minutes
login_c_US_s_42_ttl_15m:password@proxy.sotaproxy.com:10000
Static address (ISP, datacenter)
login:password@your-ip:50100, SOCKS5 on 50101

Pass server without credentials and put username and password in their own fields. Credentials inside the server URL are ignored by Chromium.

A different address per browser context

One browser, many contexts, each with its own address and its own cookie jar. That is the cheapest way to run parallel identities:

Python: one context per identity

from playwright.sync_api import sync_playwright

BASE = "http://proxy.sotaproxy.com:10000"

with sync_playwright() as p:
    browser = p.chromium.launch()
    for i in range(1, 6):
        ctx = browser.new_context(
            proxy={
                "server": BASE,
                "username": f"login_c_US_s_{i}_ttl_1h",
                "password": "password",
            },
            locale="en-US",
            timezone_id="America/New_York",
        )
        page = ctx.new_page()
        page.goto("https://example.com", timeout=30000)
  • Match locale and timezone to the proxy country. A US address with a Warsaw timezone is a contradiction that fingerprinting scripts read instantly.
  • Sticky sessions matter here. A rotation mid-page leaves half the assets loaded from another address.
  • Block images and media through routing when you only need markup. It cuts residential traffic several times over.
  • Set navigation timeouts to 30 seconds. The default 30000 milliseconds is right for us, shorter values throw away working routes.

Playwright specifics

Credentials inside server are ignored

Chromium strips them. If you see 407 in the network log, this is almost always why.

Localhost bypasses the proxy

Chromium never proxies loopback. Testing against a local mock server tells you nothing about the proxy path.

One context, many identities

Cookies and storage are per context. Reusing a context with a new address hands the site the previous identity on a new IP.

WebRTC still leaks the real address

The proxy does not cover it. Disable WebRTC in the context or the page reports your origin IP to any script that asks.

Notes & tips

  • Use headless: false during development to watch the browser and debug. Switch to headless: true for production.
  • Playwright handles HTTPS proxies automatically through CONNECT tunneling - no extra configuration needed.
  • For sticky sessions, include a session ID in the username parameter to hold the same IP across page navigations.

FAQ

Can I use Playwright with SOCKS5 proxies?

Yes. Change the server URL to socks5://proxy.sotaproxy.com:PORT. Check SotaProxy dashboard for the SOCKS5 endpoint.

Does Playwright work for scraping sites with Cloudflare protection?

Playwright with residential proxies handles most Cloudflare-protected sites. Combine with stealth plugin (playwright-extra + puppeteer-extra-plugin-stealth) for heavy Cloudflare targets.

Get your proxy credentials

Sign up, top up your balance, and copy your endpoint into Playwright. Takes under 5 minutes.

Get started