curl, Python, Node
스크립트에 바로 쓸 수 있는 예제.
Python, requests
import requests
proxy = "http://LOGIN:PASSWORD@gw.dataimpulse.com:823"
r = requests.get(
"https://ipinfo.io/json",
proxies={"http": proxy, "https": proxy},
timeout=30,
)
print(r.json())Node.js
Node에 내장된 클라이언트 undici를 사용합니다 — 추가 의존성이 없습니다.
import { ProxyAgent, fetch } from "undici";
const agent = new ProxyAgent("http://LOGIN:PASSWORD@gw.dataimpulse.com:823");
const res = await fetch("https://ipinfo.io/json", { dispatcher: agent });
console.log(await res.json());기억해 둘 것
타임아웃을 설정하세요. 가정용 주소는 데이터센터보다 느리게 응답하며, 타임아웃 없는 요청은 몇 분씩 멈춰 있을 수 있습니다.
같은 연결이 아니라 새 요청으로 재시도하세요. 포트 823에서는 재시도가 다른 주소에서 나갑니다.