통합

Shifter와 함께 사용 Node.js

몇 분 만에 Shifter의 레지덴셜 및 ISP 프록시를 모든 Node.js 프로젝트에 적용하세요. axios, 네이티브 fetch(Node 18+), got, undici, Puppeteer, Playwright와 원활하게 작동합니다.

빠른 시작

설치

npm install axios https-proxy-agent

기본 사용법

import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

const proxyUrl =
  "customer-USERNAME-country-us-sid-123ABC:PASSWORD@p.shifter.io:443";
const agent = new HttpsProxyAgent(proxyUrl);

const { data } = await axios.get("https://ipinfo.io/json", {
  httpsAgent: agent,
  proxy: false,
});

console.log(data);
// { ip: "154.16.xxx.xxx", city: "New York", country: "US", ... }

기능

axios, 네이티브 fetch, got, undici, node-fetch 및 프록시 URL 또는 에이전트를 사용하는 모든 HTTP 클라이언트에 대한 즉시 지원
기본값은 요청별 로테이션이며, 스티키 세션에는 `sid`를, N초 동안의 시간제 고정에는 `ttl-N`을 사용합니다
Puppeteer 및 Playwright를 통한 헤드리스 브라우저 지원, 한 줄 프록시 설정 가능
동일한 게이트웨이 엔드포인트에서 지원되는 HTTP, HTTPS, SOCKS5 프로토콜
사용자 이름 매개변수를 통한 195개국 이상 Geo 타겟팅 - 추가 SDK 불필요
TypeScript, ESM, CommonJS 및 14 버전 이상의 모든 Node.js LTS와 호환

예시

axios + 지역 타겟 스티키 세션

사용자 이름에 `sid`를 추가하여 전체 사용자 세션 동안 레지덴셜 IP 하나를 고정하세요. 지역적으로 타겟팅하려면 `country-uk`, `city-london`, 또는 `asn-7922`를 추가하세요.

import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";
import { randomBytes } from "node:crypto";

const sid = randomBytes(4).toString("hex");

const proxyUrl =
  `customer-USERNAME-country-uk-city-london-sid-${sid}-ttl-300:` +
  `PASSWORD@p.shifter.io:443`;

const client = axios.create({
  httpsAgent: new HttpsProxyAgent(proxyUrl),
  proxy: false,
  timeout: 30_000,
  headers: {
    "User-Agent":
      "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
  },
});

const login = await client.post("https://example.com/login", {
  email: "user@example.com",
  password: "secret",
});

const dashboard = await client.get("https://example.com/dashboard");
const orders = await client.get("https://example.com/orders");

console.log(login.status, dashboard.status, orders.status);

undici를 사용한 네이티브 fetch (Node 18+)

Node 18 이상을 사용 중이라면 axios가 필요 없습니다. undici ProxyAgent와 함께 전역 fetch를 사용하세요. 가능한 가장 작은 풋프린트입니다.

import { ProxyAgent, setGlobalDispatcher } from "undici";

const proxyAgent = new ProxyAgent({
  uri: "http://p.shifter.io:443",
  token: `Basic ${Buffer.from(
    "customer-USERNAME-country-us-sid-456DEF:PASSWORD",
  ).toString("base64")}`,
});

setGlobalDispatcher(proxyAgent);

const r = await fetch("https://api.example.com/products?page=1");
const json = await r.json();

console.log(json);

인증된 프록시를 사용하는 Puppeteer

Chromium을 Shifter를 통해 라우팅하고 page.authenticate()로 인증하세요. 전체 크롤링 동안 안정적인 세션을 유지하려면 `sid`를 브라우저 수준 쿠키와 결합하세요.

import puppeteer from "puppeteer";

const PROXY_HOST = "p.shifter.io";
const PROXY_PORT = 443;
const PROXY_USER = "customer-USERNAME-country-de-sid-789GHI";
const PROXY_PASS = "PASSWORD";

const browser = await puppeteer.launch({
  args: [`--proxy-server=http://${PROXY_HOST}:${PROXY_PORT}`],
  headless: "new",
});

const page = await browser.newPage();
await page.authenticate({ username: PROXY_USER, password: PROXY_PASS });

await page.setUserAgent(
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
);

await page.goto("https://example.com", { waitUntil: "networkidle0" });

const title = await page.title();
const html = await page.content();

console.log(title, html.length, "bytes");

await browser.close();

Playwright (다중 브라우저)

Playwright의 실행 옵션은 자격 증명을 인라인으로 포함하여 네이티브로 프록시를 지원합니다. Chromium, Firefox, WebKit에서 동일한 설정이 작동합니다.

import { chromium } from "playwright";

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

const context = await browser.newContext({
  userAgent:
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
});

const page = await context.newPage();
await page.goto("https://example.com");

const headlines = await page.locator(".headline").allTextContents();

console.log(headlines);

await browser.close();
자주 묻는 질문

자주 묻는 질문

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

httpsAgent 옵션에 https-proxy-agent(순수 HTTP의 경우 http-proxy-agent)를 전달하고, axios가 해당 에이전트를 직접 사용하도록 proxy: false로 설정하세요. 프록시 URL 형식은 `http://USER:PASS@p.shifter.io:443`입니다. 동일한 axios 인스턴스를 여러 요청에서 재사용할 수 있습니다.

예. Node 18 이상의 전역 fetch는 내부적으로 undici를 사용합니다. 프록시 URI와 기본 인증 토큰으로 undici ProxyAgent를 생성한 다음 setGlobalDispatcher(proxyAgent)를 호출하세요. 이후 모든 fetch 호출은 Shifter를 통해 라우팅됩니다.

사용자 이름에 세션 ID를 추가하세요(예: `customer-USERNAME-country-us-sid-123ABC`). 동일한 sid를 공유하는 모든 요청은 동일한 레지덴셜 IP를 재사용합니다. `ttl-300`을 추가하면 해당 IP를 최대 300초 동안 유지할 수 있습니다.

예. Puppeteer의 경우 실행 인자에 --proxy-server를 전달하고 프록시 자격 증명으로 page.authenticate()를 호출하세요. Playwright의 경우 실행 옵션의 proxy 필드에 server, username, password를 설정하세요. Chromium, Firefox, WebKit에서 동일하게 작동합니다.

프록시 사용자 이름에 국가, 지역, 도시, ASN 선택자를 추가하세요. 예를 들어 `customer-USERNAME-country-uk-city-london-sid-456DEF`는 런던의 IP를 반환합니다. 동일한 구문이 모든 Node HTTP 라이브러리에서 작동하며, SDK가 필요하지 않습니다.

SDK가 필요하지 않습니다. Shifter의 게이트웨이는 단일 엔드포인트를 통해 표준 HTTP / SOCKS5를 사용합니다. 이미 사용 중인 HTTP 클라이언트로 프록시를 설정하면 완료됩니다.

시작하기

Shifter 사용을 함께 시작하기 Node.js

5분 이내에 Shifter의 205M+ 레지덴셜 및 ISP 프록시를 Node.js 스택에 추가하세요. 요청별 로테이션, 스티키 세션, Puppeteer / Playwright 완전 지원.

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