คำตอบสั้น
ฉันจะใช้พร็อกซีดาต้าเซ็นเตอร์ในโค้ดได้อย่างไร?
ตัวอย่างโค้ดพร็อกซีเหล่านี้ส่ง URL http://USERNAME:PASSWORD@IP:PORT หนึ่งรายการไปยังไคลเอนต์ของคุณ: -x ใน curl, proxies= ใน Python requests, ProxyAgent ใน Node.js, ตัวเลือก proxy ใน Playwright SOCKS5 ใช้ socks5h:// RackProxies IP รองรับ HTTP, HTTPS (CONNECT) และ SOCKS5 เริ่มต้นที่ US$1.29 ต่อ IPv4 เฉพาะเป็นเวลา 30 วัน ไม่ต้อง KYC จ่ายด้วยคริปโตเท่านั้น
ฉันต้องใช้โค้ดตัวอย่างไหน?
| ไคลเอนต์ | พร็อกซี HTTP | พร็อกซี SOCKS5 | แพ็กเกจเพิ่มเติม |
|---|---|---|---|
| curl | -x http://… | -x socks5h://… | ไม่มี |
| Python requests | proxies={…} | URL socks5h:// | requests[socks] สำหรับ SOCKS5 |
| Python aiohttp | proxy= และ proxy_auth= | ไม่มีในตัว | aiohttp-socks สำหรับ SOCKS5 |
| Node.js fetch | undici ProxyAgent | ไม่มีในตัว | undici |
| Node.js https | https-proxy-agent | socks-proxy-agent | หนึ่งในสอง |
| Playwright | proxy: { server, username, password } | ใช้ HTTP หรือ allowlist | playwright |
ฉันจะใช้พร็อกซีกับ curl ได้อย่างไร?
ส่ง URL พร็อกซีด้วย -x curl จัดการอุโมงค์ CONNECT สำหรับเป้าหมาย https:// ด้วยตัวเอง ทุกโค้ดตัวอย่างในหน้านี้ใช้ที่อยู่เอกสาร 203.0.113.24; หน้า รูปแบบการเชื่อมต่อ แสดงวิธีสร้าง URL จากบรรทัดของคุณ
# HTTP proxy, HTTPS target (CONNECT tunnel)
curl -x http://USERNAME:[email protected]:8000 https://api.ipify.org
# SOCKS5, hostname resolved by the proxy
curl -x socks5h://USERNAME:[email protected]:8000 https://api.ipify.org
# Login passed separately (no URL-encoding needed)
curl -x http://203.0.113.24:8000 -U 'USERNAME:PASSWORD' https://httpbin.org/ip
# IP allowlist: no login
curl -x http://203.0.113.24:8000 https://api.ipify.org
# Show the proxy handshake and the timings
curl -v -s -o /dev/null -w '%{time_connect} %{time_appconnect} %{time_total}\n' \
-x http://USERNAME:[email protected]:8000 https://example.comฉันจะใช้พร็อกซีกับ Python requests ได้อย่างไร?
ให้ requests พจนานุกรม proxies ที่มี URL เดียวกันสำหรับ http และ https คีย์ https คือคีย์ที่ใช้สำหรับเป้าหมาย https://; ค่าของมันยังคงเริ่มต้นด้วย http:// เพราะมันอธิบายการเชื่อมต่อไปยังพร็อกซี requests จะเกิดข้อผิดพลาด ProxyError เมื่อพร็อกซีปฏิเสธการเชื่อมต่อหรือการล็อกอิน
import requests # pip install requests
# From the line 203.0.113.24:8000:USERNAME:PASSWORD in your account
proxy = 'http://USERNAME:[email protected]:8000'
proxies = {'http': proxy, 'https': proxy}
try:
response = requests.get('https://api.ipify.org', proxies=proxies, timeout=20)
response.raise_for_status()
print('Exit IP:', response.text)
except requests.exceptions.ProxyError as error:
print('Proxy problem (credentials, port or allowlist):', error)
except requests.exceptions.Timeout:
print('No answer within 20 seconds')import requests # pip install "requests[socks]"
# socks5h: the proxy resolves the hostname. Use the SOCKS5 port shown in your account.
proxy = 'socks5h://USERNAME:[email protected]:8000'
proxies = {'http': proxy, 'https': proxy}
response = requests.get('https://httpbin.org/ip', proxies=proxies, timeout=20)
print(response.json()) # {'origin': '203.0.113.24'}import requests
# A Session reuses connections: faster for many requests through the same IP.
session = requests.Session()
session.proxies.update({
'http': 'http://USERNAME:[email protected]:8000',
'https': 'http://USERNAME:[email protected]:8000',
})
session.headers['User-Agent'] = 'my-monitor/1.0 (contact: [email protected])'
for url in ['https://example.com', 'https://httpbin.org/ip']:
response = session.get(url, timeout=20)
print(url, response.status_code, len(response.content), 'bytes')ตั้งค่า User-Agent ที่ระบุชื่อเครื่องมือและช่องทางติดต่อ ดังในตัวอย่าง Session: เจ้าของไซต์จะติดต่อคุณได้แทนการบล็อก requests ยังอ่าน environment variable HTTP_PROXY และ HTTPS_PROXY ด้วยเมื่อไม่ได้ระบุอาร์กิวเมนต์ proxies
ฉันจะใช้พร็อกซีกับ Python aiohttp ได้อย่างไร
aiohttp รับพร็อกซีต่อคำขอ: proxy= สำหรับที่อยู่ และ proxy_auth= สำหรับการเข้าสู่ระบบ รองรับพร็อกซี HTTP รวมถึง CONNECT สำหรับเป้าหมาย https:// สำหรับ SOCKS5 ต้องใช้แพ็กเกจ aiohttp-socks แยกต่างหาก
import asyncio
import aiohttp # pip install aiohttp (HTTP proxies; SOCKS needs the aiohttp-socks package)
PROXY = 'http://203.0.113.24:8000'
AUTH = aiohttp.BasicAuth('USERNAME', 'PASSWORD')
async def main():
timeout = aiohttp.ClientTimeout(total=20)
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.get('https://httpbin.org/ip', proxy=PROXY, proxy_auth=AUTH) as response:
print(await response.json())
asyncio.run(main())ฉันจะใช้พร็อกซีกับ Node.js ได้อย่างไร
fetch ที่มีมาใน Node ไม่รับอาร์กิวเมนต์พร็อกซี ให้ใช้แพ็กเกจ undici และ ProxyAgent เป็น dispatcher สำหรับโมดูล https แบบคลาสสิก ให้ใช้ https-proxy-agent สำหรับพร็อกซี HTTP และ socks-proxy-agent สำหรับ SOCKS5 ทั้งสองตัวอย่างเป็น ES module: บันทึกเป็นไฟล์ .mjs
// npm install undici
import { ProxyAgent, fetch } from 'undici';
const dispatcher = new ProxyAgent({
uri: 'http://203.0.113.24:8000',
token: `Basic ${Buffer.from('USERNAME:PASSWORD').toString('base64')}`,
});
const response = await fetch('https://api.ipify.org', { dispatcher });
console.log('Exit IP:', await response.text());// npm install https-proxy-agent socks-proxy-agent
import https from 'node:https';
import { HttpsProxyAgent } from 'https-proxy-agent';
import { SocksProxyAgent } from 'socks-proxy-agent';
const httpAgent = new HttpsProxyAgent('http://USERNAME:[email protected]:8000');
// Use the SOCKS5 port shown in your account; socks5h lets the proxy resolve DNS.
const socksAgent = new SocksProxyAgent('socks5h://USERNAME:[email protected]:8000');
for (const agent of [httpAgent, socksAgent]) {
https.get('https://api.ipify.org', { agent }, (res) => {
res.setEncoding('utf8');
res.on('data', (chunk) => console.log('Exit IP:', chunk));
}).on('error', (err) => console.error('Proxy error:', err.message));
}ฉันจะใช้พร็อกซีกับ Playwright ได้อย่างไร
ส่งออบเจกต์ proxy ให้ chromium.launch() พร้อม server และแยก username กับ password ใช้อแบบ HTTP: ไคลเอนต์ SOCKS5 ที่มีมาใน Chromium ไม่รองรับการยืนยันตัวตนด้วย username และ password สำหรับพร็อกซี SOCKS5 หากใช้ allowlist ของ IP ให้ละเว้น username และ password
// npm install playwright && npx playwright install chromium
import { chromium } from 'playwright';
const browser = await chromium.launch({
proxy: { server: 'http://203.0.113.24:8000', username: 'USERNAME', password: 'PASSWORD' },
});
const page = await browser.newPage();
await page.goto('https://api.ipify.org');
console.log('Exit IP:', await page.textContent('body'));
await browser.close();ใช้เบราว์เซอร์ผ่านพร็อกซีสำหรับ QA ไซต์ของคุณเอง การตรวจสอบโฆษณาและการแปล และงานที่ถูกกฎหมายในลักษณะเดียวกัน โปรดจำไว้ว่าพร็อกซีเปลี่ยนเฉพาะ IP: ภาษาและเขตเวลาของเบราว์เซอร์ยังคงเป็นของเครื่องคุณ เว้นแต่คุณจะตั้งค่าในบริบทของเบราว์เซอร์
ฉันจะวัด latency ผ่านพร็อกซีได้อย่างไร
จับเวลาคำขอที่สมบูรณ์หลายครั้งแล้วใช้ค่ามัธยฐาน สคริปต์ Python ด้านล่างส่งห้าคำขอไปยัง https://example.com ผ่าน IP เดียว รันผ่าน IP ในเมืองศูนย์ข้อมูลต่างๆ เพื่อเปรียบเทียบ คู่มือเมือง อธิบายพื้นทางกายภาพสำหรับแต่ละระยะทาง
import statistics
import time
import requests
proxy = 'http://USERNAME:[email protected]:8000'
timings = []
for _ in range(5):
start = time.perf_counter()
requests.get('https://example.com', proxies={'http': proxy, 'https': proxy}, timeout=20)
timings.append((time.perf_counter() - start) * 1000)
print(f'median {statistics.median(timings):.0f} ms over {len(timings)} requests')ฉันจะใช้รายการ IP ทั้งหมดได้อย่างไร
โหลดไฟล์ TXT ที่ส่งออก แปลงแต่ละบรรทัดเป็น URL และเลือก IP ต่อคำขอ: หมุนเวียนข้ามไซต์ หรือใช้ IP เดียวกันสำหรับไซต์เดียวกัน คู่มือ rotating กับ static มีตัวอย่างครบถ้วน และหน้า รูปแบบการเชื่อมต่อ มีตัวแปลงสำหรับทั้งรายการ เคารพจังหวะของแต่ละไซต์ไม่ว่าคุณจะมีรายการขนาดใด: IP ที่มากขึ้นไม่ได้เพิ่มขีดจำกัดของไซต์
คำถามเกี่ยวกับตัวอย่างโค้ด
ทำไมฉันใช้ http:// สำหรับพร็อกซีเมื่อไซต์เป็น https://?
scheme ของ URL พร็อกซีอธิบายการเชื่อมต่อของคุณกับพร็อกซี ไม่ใช่กับเว็บไซต์ ไคลเอนต์ของคุณเชื่อมต่อกับพร็อกซีผ่าน TCP ธรรมดา ขอให้เปิดทันเนล CONNECT แล้วจึงรัน TLS กับเว็บไซต์ภายใน เนื้อหาหน้าจะยังเข้ารหัสแบบ end to end; มีเพียงการเข้าสู่ระบบพร็อกซีที่เดินทางในรูปแบบที่อ่านได้
รหัสผ่านของฉันมีอักขระพิเศษ มีอะไรเปลี่ยนแปลง?
ในรูปแบบ URL ให้เข้ารหัสรหัสผ่านด้วย urllib.parse.quote(password, safe='') ใน Python หรือ encodeURIComponent(password) ใน JavaScript ไคลเอนต์ที่รับการเข้าสู่ระบบแยกต่างหาก เช่น BasicAuth ของ aiohttp, username และ password ของ Playwright หรือ -U ของ curl ไม่ต้องเข้ารหัส หน้า รูปแบบการเชื่อมต่อ แสดงรายการอักขระ
ทำไม requests บอกว่าขาด dependency สำหรับการรองรับ SOCKS?
การรองรับ SOCKS ของ requests อยู่ใน extra แบบเลือกติดตั้ง ติดตั้งด้วย pip install "requests[socks]" ซึ่งจะเพิ่ม PySocks และใช้ URL socks5h:// เพื่อให้พร็อกซีแปลงชื่อโฮสต์ พร็อกซี HTTP ทำงานได้โดยไม่ต้องมีแพ็กเกจเพิ่ม所以你สามารถเปลี่ยน URL เป็น http:// และเก็บ dependency เดิมไว้ได้
ฉันสามารถรันคำขอจำนวนมากแบบขนานผ่าน IP เดียวได้หรือไม่
ได้ ภายในการใช้งานอย่างเป็นธรรม เราไม่เผยแพร่ขีดจำกัดการเชื่อมต่อต่อ IP รักษาระดับการทำงานขนานให้เหมาะสมเพื่อความเสถียรของคุณเอง และรักษาจังหวะของแต่ละเว็บไซต์: คำขอแบบขนานไปยังไซต์เดียวกันยังนับรวมกับขีดจำกัดของไซต์นั้น คิดค่าบริการเป็นราย IP 30 วัน ไม่ใช่ราย GB ภายใต้นโยบายการใช้งานอย่างเป็นธรรม
โค้ดของฉันควรเรียก URL ทดสอบใดก่อน
เรียก https://api.ipify.org หรือ https://httpbin.org/ip: แต่ละตัวจะคืนค่า IP ที่มองเห็น เพื่อให้คุณยืนยันได้ว่าทราฟฟิกออกจากพร็อกซีของคุณ จากนั้นเรียกเป้าหมายจริงของคุณ หาก URL ทดสอบทำงานแต่เป้าหมายไม่ทำงาน ปัญหาอยู่ระหว่างพร็อกซีกับเป้าหมาย ไม่ใช่ในโค้ดของคุณ
ฉันต้องใช้บัตรประชาชนเพื่อรับพร็อกซีสำหรับตัวอย่างเหล่านี้หรือไม่
ไม่ต้อง ไม่ต้อง KYC: ไม่ต้องใช้เอกสารระบุตัวตน ไม่ต้องเซลฟี่ ไม่ต้องลงนามเอกสารใด ๆ เพื่อสมัคร เติมเงิน หรือซื้อ เติมเงินใน BTC, USDT, USDC, ETH, SOL, LTC ซื้อแพ็กเกจจาก US$1.29 และคัดลอกบรรทัดจากบัญชีของคุณไปยังตัวอย่างโค้ด ดู ราคา สำหรับทุกขนาดแพ็กเกจ
รันตัวอย่างด้วย IP ของคุณเอง
1 IP สำหรับ US$1.29 รวม HTTP และ SOCKS5 ไม่ต้อง KYC จ่ายด้วยคริปโต
ข้อมูลอ้างอิง (6)
- หน้า man ของ curl — curl project (2026-10-19)
- Requests: พร็อกซีและ SOCKS — Requests (2026-10-19)
- aiohttp: การรองรับพร็อกซี — aiohttp (2026-10-19)
- undici: ProxyAgent — Node.js (2026-10-19)
- proxy-agents (https-proxy-agent, socks-proxy-agent) — GitHub (2026-10-19)
- Playwright: พร็อกซี HTTP — Playwright (2026-10-19)