Puppeteer·Playwright와 XProxy 연동

Puppeteer와 Playwright 자동화 스크레이퍼를 XProxy 모바일 채널을 통해 라우팅하는 완전한 코드 예제가 포함된 개발자 가이드입니다. 프록시 인증 처리와 자동 IP 로테이션을 포함합니다.

XProxy 콘솔 프록시 내보내기 및 포트 설정

Puppeteer 통합 (Node.js)

Puppeteer는 실행 인수에서 프록시 서버를 전달할 수 있습니다. XProxy에 인증이 필요하면 탐색 전에 page.authenticate()를 사용해야 합니다.

puppeteer_example.js
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    headless: true,
    args: [
      // Route all traffic through XProxy SOCKS5 or HTTP port
      '--proxy-server=socks5://192.168.6.7:5001' 
    ]
  });

  const page = await browser.newPage();

  // If XProxy auth is enabled, authenticate here:
  await page.authenticate({
    username: 'your_xproxy_username',
    password: 'your_xproxy_password'
  });

  await page.goto('https://httpbin.org/ip');
  const body = await page.evaluate(() => document.body.innerText);
  console.log('Exit IP:', body);

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

Playwright 통합 (Node.js)

Playwright는 브라우저 실행 옵션에서 자격 증명 매개변수를 포함해 프록시 구성을 기본적으로 지원합니다. 별도의 페이지 인증 단계가 필요 없습니다.

playwright_example.js
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({
    proxy: {
      server: 'socks5://192.168.6.7:5001',
      // Optional credentials if authentication is enabled in XProxy Settings:
      username: 'your_xproxy_username',
      password: 'your_xproxy_password'
    }
  });

  const context = await browser.newContext();
  const page = await context.newPage();

  await page.goto('https://httpbin.org/ip');
  const body = await page.locator('body').innerText();
  console.log('Exit IP:', body);

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

Playwright 통합 (Python)

웹 자동화 또는 SEO 랭크 체커를 실행하는 Python 개발자를 위한 안내:

playwright_example.py
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(
        proxy={
            "server": "socks5://192.168.6.7:5001",
            # Optional credentials:
            "username": "your_xproxy_username",
            "password": "your_xproxy_password"
        }
    )
    
    page = browser.new_page()
    page.goto("https://httpbin.org/ip")
    print("Exit IP:", page.inner_text("body"))
    
    browser.close()

스크립트에서 IP 로테이션 트리거

실행 또는 주기마다 새 IP 주소가 필요하면 탐색 전에 XProxy의 위치 기반 로테이션 API에 간단한 HTTP GET 요청을 보냅니다:

Node.js Rotation Trigger
const axios = require('axios');

async function rotateIP() {
  try {
    const response = await axios.get('http://192.168.6.7:8081/api/v1/rotate_ip/position/1');
    console.log('Rotate response:', response.data);
    // Wait 5-8 seconds for 4G/5G cellular reconnection to complete
    await new Promise(resolve => setTimeout(resolve, 6000));
  } catch (error) {
    console.error('IP rotation failed:', error.message);
  }
}

Why High-Quality SOCKS5 UDP & Mobile Proxies Matter for Puppeteer & Playwright

Using cheap datacenter proxies or basic HTTP proxies in antidetect profiles leads to instant account suspensions on Facebook, Google, TikTok, and Amazon. Here is why XProxy's self-hosted 4G/5G mobile proxies deliver superior anonymity and trust:

  • SOCKS5 with Full UDP Support: Unlike standard HTTP proxies that drop UDP packets, XProxy SOCKS5 proxies fully support UDP datagrams. This ensures WebRTC, DNS queries, and real-time audio/video sockets route securely through your proxy without revealing your real IP address.
  • Instant REST API IP Rotation: Trigger cellular IP rotation on demand via simple HTTP GET requests (e.g. http://192.168.6.7:8081/api/v1/rotate_ip/position/1). Reconnect 4G/5G USB modems in 3 to 8 seconds with zero proxy dropouts.
  • 100% WebRTC & DNS Leak Protection: Combined with XProxy's local LAN gateway and TCP OS Spoofing, your browser profiles maintain pristine anonymity scores on BrowserLeaks, Whoer, Pixelscan, and IPhey.
  • Carrier-Grade NAT (CGNAT) Trust: Mobile carrier IPs are shared by thousands of active smartphone users. Major platforms never ban mobile IP ranges, granting your accounts maximum trust.
🚀 Build Your Own 4G/5G Proxy Farm

Stop Paying Monthly Rented Proxy Fees

XProxy hardware & software lets you own private mobile proxy channels with unlimited data, zero bandwidth caps, SOCKS5 UDP support, and instant REST API IP rotation (Puppeteer & Playwright).

XProxy XH22 4G 5G Mobile Proxy Hardware Kit