Tích hợp proxy với Playwright

Playwright has first-class proxy support, so there is no extension trick or separate authenticate call. Pass a proxy object with server, username and password to launch(), and it applies across Chromium, Firefox and WebKit. You can also set the proxy per context when different pages need different IPs.

run.jsjavascript
import { chromium } from "playwright";

const browser = await chromium.launch({
  proxy: {
    // Residential gateway, or "http://IP:PORT" for one of your ISP proxies.
    server: "http://gw-eu.murphyproxies.com:8888",
    username: "USERNAME",
    password: "PASSWORD",
  },
});

const page = await browser.newPage();
await page.goto("https://httpbin.org/ip");
console.log(await page.textContent("body"));

await browser.close();

// Per-context proxy (e.g. a US exit in one context, an ISP IP in another):
// const context = await browser.newContext({
//   proxy: { server: "http://gw-usa.murphyproxies.com:8888",
//            username: "USERNAME", password: "PASSWORD" },
// });

Cài đặt trong 5 bước

  1. 1Install the client with npm install playwright.
  2. 2Pass a proxy object (server, username, password) to chromium.launch().
  3. 3Point server at http://gw-eu.murphyproxies.com:8888 (another gw- region, port 7777 on Private 2, or http://IP:PORT for an ISP proxy) with the credentials from your dashboard.
  4. 4Open a page and navigate to an IP echo endpoint to verify the exit IP.
  5. 5Move the proxy onto newContext() when you need separate IPs across parallel work.

Câu hỏi về proxy cho Playwright

Mọi điều bạn cần để định tuyến Playwright qua Murphy, từ xác thực đến xoay vòng IP.

Nhận thông tin đăng nhập cho Playwright

Chọn mạng lưới hợp với mục tiêu của bạn. Proxy ISP cho phiên nhanh và ổn định, proxy dân cư cho nguồn IP đa dạng trước các hệ thống chống bot khắt khe.