Playwright

This guide explains how to use Evomi proxies with Playwright, a modern browser automation library with built-in proxy authentication support. Examples are provided for both JavaScript/TypeScript and Python.

Prerequisites

  • Node.js 18+ (for JavaScript) or Python 3.8+ (for Python)
  • Playwright installed in your project
  • Your Evomi proxy credentials (username and password)

Installation

JavaScript:

npm install playwright
npx playwright install

Python:

pip install playwright
playwright install

Configuration

Playwright natively supports proxy authentication – no extensions or workarounds needed. You can configure the proxy at the browser level (applies to all pages) or at the context level (different proxies per context).

Browser-Level Proxy

This applies the proxy to all pages opened by this browser instance.

JavaScript:

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

(async () => {
  const browser = await chromium.launch({
    proxy: {
      server: 'http://rp.evomi.com:1000',
      username: 'your_username',
      password: 'your_password_session-anychars_mode-speed'
    }
  });

  const page = await browser.newPage();
  await page.goto('https://ip.evomi.com/s');
  console.log(await page.textContent('body'));

  await browser.close();
})();

Python:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(proxy={
        "server": "http://rp.evomi.com:1000",
        "username": "your_username",
        "password": "your_password_session-anychars_mode-speed"
    })

    page = browser.new_page()
    page.goto("https://ip.evomi.com/s")
    print(page.text_content("body"))

    browser.close()

Context-Level Proxy

Use different proxies for different browser contexts within the same browser instance. This is useful for multi-region testing or rotating proxies.

JavaScript:

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

(async () => {
  const browser = await chromium.launch({
    proxy: { server: 'per-context' }
  });

  const usContext = await browser.newContext({
    proxy: {
      server: 'http://rp.evomi.com:1000',
      username: 'your_username',
      password: 'your_password_session-anychars_country-us'
    }
  });

  const dePage = await (await browser.newContext({
    proxy: {
      server: 'http://rp.evomi.com:1000',
      username: 'your_username',
      password: 'your_password_session-anychars_country-de'
    }
  })).newPage();

  const usPage = await usContext.newPage();
  await usPage.goto('https://ip.evomi.com/s');
  console.log('US proxy IP:', await usPage.textContent('body'));

  await dePage.goto('https://ip.evomi.com/s');
  console.log('DE proxy IP:', await dePage.textContent('body'));

  await browser.close();
})();
â„šī¸
On Chromium on Windows, you must pass proxy: { server: 'per-context' } at the browser level to enable context-specific proxies. On other platforms and browsers, this is not required.

Using SOCKS5

Replace the server URL to use the SOCKS5 endpoint:

proxy: {
  server: 'socks5://rp.evomi.com:1002',
  username: 'your_username',
  password: 'your_password_session-anychars_mode-speed'
}

Evomi Proxy Endpoints

Proxy Type HTTP HTTPS SOCKS5
Residential rp.evomi.com:1000 rp.evomi.com:1001 rp.evomi.com:1002
Mobile mp.evomi.com:3000 mp.evomi.com:3001 mp.evomi.com:3002
Datacenter dcp.evomi.com:2000 dcp.evomi.com:2001 dcp.evomi.com:2002

Running the Script

JavaScript:

node proxy_test.js

Python:

python proxy_test.py

The script will print the proxy IP to the console.

Tips and Troubleshooting

  • Credentials: Double-check your username and password. The password format is your_password_session-anychars_mode-speed.
  • Browser choice: Playwright supports Chromium, Firefox, and WebKit. All three support proxy configuration. Replace chromium with firefox or webkit as needed.
  • Headless mode: Playwright runs headless by default. Add headless: False (Python) or headless: false (JS) to launch() to see the browser window.
  • Timeouts: For slow proxy connections, increase the navigation timeout: page.goto(url, { timeout: 60000 }).
  • Proxy bypass: To exclude specific hosts from the proxy, add a bypass field: proxy: { server: '...', bypass: 'localhost,127.0.0.1' }.