통합

Shifter와 함께 사용 Playwright

Chromium, Firefox, WebKit을 Shifter의 레지덴셜 및 ISP 프록시를 통해 실행하세요. 자격 증명을 인라인으로 사용하며 사이드카 확장 프로그램이 필요하지 않습니다. Node, Python, Java, .NET 전반에서 최고 수준의 프록시 지원을 제공합니다.

빠른 시작

설치

npm install playwright

기본 사용법

import { chromium } from "playwright";

const browser = await chromium.launch({
  proxy: {
    server: "http://p.shifter.io:443",
    username: "customer-USERNAME-country-us-sid-123ABC",
    password: "PASSWORD",
  },
});

const page = await browser.newPage();
await page.goto("https://ipinfo.io/json");
console.log(await page.textContent("body"));
// {"ip": "154.16.xxx.xxx", "city": "New York", "country": "US", ...}

await browser.close();

기능

자격 증명을 인라인으로 포함한 네이티브 프록시 지원, 사이드카 확장 프로그램이나 브라우저 설정 변경이 필요하지 않습니다
동일한 설정이 지원되는 모든 플랫폼에서 Chromium, Firefox, WebKit에 적용됩니다
컨텍스트별 프록시 설정을 사용하면 하나의 브라우저 인스턴스 내에서 여러 국가를 혼합할 수 있습니다
Node, Python, Java, .NET 전반에 걸쳐 동일한 API, 모든 언어에서 동일한 프록시 딕셔너리
사용자 이름 매개변수를 통한 195개국 이상 Geo 타겟팅 - country, region, city, ASN
기본값은 요청별 로테이션이며, 스티키 세션에는 `sid`를, N초 동안의 시간제 고정에는 `ttl-N`을 사용합니다

예시

컨텍스트별 지역 타겟팅 (브라우저 하나, 여러 지역)

각 브라우저 컨텍스트는 자체 프록시를 가질 수 있습니다. 하나의 브라우저 인스턴스 안에서 US 컨텍스트, UK 컨텍스트, JP 컨텍스트를 실행하세요. 병렬 현지화 스크레이핑을 위한 Playwright의 킬러 기능입니다.

import { chromium } from "playwright";

const browser = await chromium.launch();

async function makeContext(country: string, sid: string) {
  return browser.newContext({
    proxy: {
      server: "http://p.shifter.io:443",
      username: `customer-USERNAME-country-${country}-sid-${sid}`,
      password: "PASSWORD",
    },
    userAgent:
      "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
  });
}

const [us, uk, jp] = await Promise.all([
  makeContext("us", "us-001"),
  makeContext("uk", "uk-001"),
  makeContext("jp", "jp-001"),
]);

const [usPage, ukPage, jpPage] = await Promise.all([
  us.newPage(),
  uk.newPage(),
  jp.newPage(),
]);

await Promise.all([
  usPage.goto("https://www.example.com"),
  ukPage.goto("https://www.example.co.uk"),
  jpPage.goto("https://www.example.jp"),
]);

console.log({
  us: await usPage.title(),
  uk: await ukPage.title(),
  jp: await jpPage.title(),
});

await browser.close();

다중 브라우저 (Chromium / Firefox / WebKit)

세 가지 엔진 모두에서 동일한 프록시 설정을 사용합니다. 크로스 브라우저 스크래핑이나 특정 대상에서 봇 탐지를 유발할 가능성이 가장 낮은 엔진을 선택하는 데 유용합니다.

import { chromium, firefox, webkit, type BrowserType } from "playwright";

const proxy = {
  server: "http://p.shifter.io:443",
  username: "customer-USERNAME-country-de-city-berlin-sid-456DEF",
  password: "PASSWORD",
};

async function visit(engine: BrowserType, label: string) {
  const browser = await engine.launch({ proxy });
  const page = await browser.newPage();
  await page.goto("https://example.de");
  const title = await page.title();
  await browser.close();
  return { label, title };
}

const results = await Promise.all([
  visit(chromium, "chromium"),
  visit(firefox, "firefox"),
  visit(webkit, "webkit"),
]);

console.log(results);

Playwright 테스트 스위트

playwright.config.ts에서 Shifter를 한 번 구성하여 모든 테스트가 프록시를 통과하도록 하세요. 자격 증명을 소스에 커밋하지 않도록 환경 변수를 사용하세요.

// playwright.config.ts
import { defineConfig } from "@playwright/test";

export default defineConfig({
  testDir: "./tests",
  workers: 4,

  use: {
    proxy: {
      server: "http://p.shifter.io:443",
      username: process.env.SHIFTER_USER!, // e.g. customer-USERNAME-country-us-sid-test
      password: process.env.SHIFTER_PASS!,
    },
    userAgent:
      "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
    viewport: { width: 1920, height: 1080 },
    ignoreHTTPSErrors: false,
  },
});

// tests/products.spec.ts
import { test, expect } from "@playwright/test";

test("US homepage renders", async ({ page }) => {
  await page.goto("https://example.com");
  await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
});

test("Product page parses", async ({ page }) => {
  await page.goto("https://example.com/products/123");
  const price = await page.locator(".price").textContent();
  expect(price).toMatch(/^\$\d+/);
});

Python: Sticky Session을 사용한 chromium.launch

Playwright는 언어 간에 동일합니다. Python에서도 동일한 딕셔너리 형태의 프록시 설정을 사용하며, 나머지 API도 Node 버전과 동일합니다.

# pip install playwright
# playwright install chromium

import asyncio
import secrets
from playwright.async_api import async_playwright

async def main():
    sid = secrets.token_hex(4)

    async with async_playwright() as p:
        browser = await p.chromium.launch(
            proxy={
                "server": "http://p.shifter.io:443",
                "username": f"customer-USERNAME-country-fr-city-paris-sid-{sid}-ttl-300",
                "password": "PASSWORD",
            }
        )

        context = await browser.new_context(
            user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36",
        )

        page = await context.new_page()

        # Multi-step flow — same residential IP across every navigation.
        await page.goto("https://example.fr/login", wait_until="networkidle")
        await page.fill("#email", "user@example.com")
        await page.fill("#password", "secret")
        await page.click("button[type=submit]")
        await page.wait_for_url("**/dashboard")

        rows = await page.locator(".order-row").all_text_contents()
        print(f"Found {len(rows)} orders")

        await browser.close()

asyncio.run(main())
자주 묻는 질문

자주 묻는 질문

Playwright와 Shifter 사용에 관한 일반적인 질문.

브라우저 실행 옵션에 `server`, `username`, `password`가 포함된 `proxy` 필드를 전달하세요. Chromium, Firefox, WebKit에서 동일한 형태입니다. 자격 증명은 인라인으로 전달되므로 별도의 확장 프로그램이 필요 없으며, 헤드리스 모드에서도 바로 작동합니다.

예. `browser.newContext()`에 `proxy`를 전달하면 해당 컨텍스트는 브라우저의 나머지 부분과 다른 프록시를 사용합니다. 이는 하나의 프로세스 내에서 여러 국가를 병렬로 스크레이핑하는 가장 깔끔한 방법이며, 여러 브라우저를 실행하는 것보다 훨씬 메모리 효율적입니다.

예. 동일한 프록시 설정이 세 엔진 모두에서 작동합니다. 타겟이 Chrome 전용 봇 탐지를 사용할 때 Firefox와 WebKit이 유용합니다. Playwright는 엔진 전환이 한 줄 변경으로 가능한 몇 안 되는 도구 중 하나입니다.

프록시 사용자 이름에 세션 ID를 추가하세요(예: `customer-USERNAME-country-us-sid-123ABC`). 해당 컨텍스트 내의 모든 탐색, 요청, 탭은 동일한 레지덴셜 IP를 재사용합니다. `ttl-N`을 추가하면 최대 N초 동안 이를 고정할 수 있습니다.

예. `playwright.config.ts` 파일에서 `use.proxy` 필드를 설정하세요. 이를 재정의하지 않는 모든 테스트는 Shifter 프록시를 상속받습니다. 자격 증명이 소스 관리에 남지 않도록 환경 변수를 사용하세요.

예, Playwright는 Python, Java, .NET용 공식 클라이언트를 제공합니다. 프록시 설정은 모든 언어에서 동일한 형태(server, username, password)를 사용합니다. 이 페이지의 예시는 Node와 Python 모두를 보여주지만, 동일한 설정이 어디서든 동작합니다.

시작하기

Shifter 사용을 함께 시작하기 Playwright

Shifter의 205M+ 레지덴셜 및 ISP 프록시를 통해 Chromium, Firefox, WebKit을 구동하세요. 인라인 자격 증명으로 확장 프로그램이 필요 없습니다. Node, Python, Java, .NET 전반에서 작동합니다.

Shifter 무료로 체험하기몇 분 만에 설정. 언제든지 취소 가능.