Node.js හි ප්රොක්සියක් සකසන්නේ කෙසේද (Axios සහ Native Fetch)
Updated:
Axios හි ඇති proxy: { host, port } විකල්පය මඟින් HTTP CONNECT ටනලයක් විවෘත නොකරන බැවින් එය https:// ඉලක්ක සඳහා අසාර්ථක වේ. Node.js සහ TypeScript ඉල්ලීම් VinaProxy සහතික කළ HTTP(S) ප්රොක්සි හරහා නිවැරදිව යොමු කිරීමට, Axios වෙත HttpsProxyAgent (https-proxy-agent) එකක් හෝ ස්වදේශීය Node fetch() වෙත undici.ProxyAgent ඩිස්පැචරයක් ලබා දෙන්න.
new HttpsProxyAgent('http://user:pass@ip:port')- IP 1₫40,000
- IP 5+₫35,000
- IP 10+₫25,000
- IP 20+₫25,000
- IP 50+₫25,000
- IP 100+₫25,000
- IP 200+₫25,000
- IP 500+₫25,000
- IP 1000+₫22,000
- IP 2000+₫20,000
- IP 1₫40,000
- IP 5+₫35,000
- IP 10+₫25,000
- IP 20+₫25,000
- IP 50+₫25,000
- IP 100+₫25,000
- IP 200+₫25,000
- IP 500+₫25,000
- IP 1000+₫22,000
- IP 2000+₫20,000
Axios සහ ස්වදේශීය Node.js fetch() ප්රොක්සි සැකසුම සංසන්දනය
පුස්තකාල දෙකම ඔබගේ VinaProxy උපකරණ පුවරුවෙන් ලබාදෙන සම්මත http://user:pass@ip:port URL පිළිගනී:
| HTTP ක්ලයන්ට් | පැකේජය | නිර්දේශිත කේත ඛණ්ඩය |
|---|---|---|
| Axios | npm i https-proxy-agent | axios.get(url, { httpsAgent: new HttpsProxyAgent('http://user:pass@ip:port'), proxy: false }) |
Native fetch (Node 18+) | npm i undici | fetch(url, { dispatcher: new ProxyAgent('http://user:pass@ip:port') }) |
| Got | npm i hpagent | got(url, { agent: { https: new HttpsProxyAgent({ proxy: 'http://user:pass@ip:port' }) } }) |
Node.js හි Connection pooling සහ timeout සඳහා හොඳම භාවිතයන්
- පද්ධතියේ පවතින
HTTP_PROXYපරිසර විචල්යයන් සමඟ ඇතිවන ගැටලු මඟහරවා ගැනීමට Axios හිhttpsAgentසමඟ සෑම විටමproxy: falseසකසන්න - ස්ථාවර keep-alive සොකට් නැවත භාවිතය සඳහා ඔබගේ ලූපයට පිටතින් එක් ප්රොක්සි IP එකකට එක් වරක් බැගින්
HttpsProxyAgentහෝProxyAgentසාදන්න - අපගේ Proxy Format Converter භාවිතයෙන් ඔබගේ VinaProxy ප්රොක්සි ලැයිස්තුව ඍජුවම JSON array එකක් ලෙස ලබාගන්න
පියවරෙන් පියවර
- 1
https-proxy-agent (හෝ undici) ස්ථාපනය කරන්න
ඔබගේ Node.js ව්යාපෘතිය තුළ
npm install axios https-proxy-agentධාවනය කරන්න. - 2
HttpsProxyAgent අවස්ථාව සාදන්න
ඔබගේ VinaProxy අක්තපත්ර භාවිතයෙන්
const agent = new HttpsProxyAgent('http://user:pass@ip:port');ආරම්භ කරන්න. - 3
Axios වෙත httpsAgent සහ proxy: false ලබා දෙන්න
const res = await axios.get('https://vinaproxy.com/api/my-ip', { httpsAgent: agent, proxy: false, timeout: 10000 });අමතන්න. - 4
පිටවීමේ IP ලිපිනය තහවුරු කරන්න
ප්රතිචාරය ඔබගේ වෙන්කළ ප්රොක්සි IP එක හරහා ලැබුණු බව තහවුරු කිරීමට
res.dataලොග් කරන්න.
නිතර අසන ප්රශ්න
HTTPS URL සඳහා Axios හි පෙරනිමි `proxy: { host, port, auth }` අසාර්ථක වන්නේ ඇයි?
Axios හි ඇති ප්රොක්සි සැකසුම මඟින් HTTP CONNECT TLS ටනලයක් විවෘත කරනවා වෙනුවට සාමාන්ය HTTP ඉල්ලීමක් යවයි. proxy: false සමඟ httpsAgent: new HttpsProxyAgent('http://user:pass@ip:port') භාවිත කිරීමෙන් මෙය නිවැරදි කරගත හැක.
Node.js 18/20/22 හි ස්වදේශීය `fetch()` සමඟ ප්රොක්සියක් භාවිත කරන්නේ කෙසේද?
undici වෙතින් ProxyAgent ආයාත කර, fetch() විකල්ප වස්තුව තුළ { dispatcher: new ProxyAgent('http://user:pass@ip:port') } ලබා දෙන්න.
Node.js සඳහා මගේ ප්රොක්සි ලැයිස්තුව JSON බවට පරිවර්තනය කළ හැකිද?
ඔව්—අපගේ නොමිලේ ලබාදෙන Proxy Format Converter වෙත ඔබගේ ip:port:user:pass පේළි ඇතුළත් කර JSON ප්රතිදානය තෝරන්න.
ස්ථාවර IP සමඟ ඔබගේ Node.js පසුඅන්ත සහ scraper සවිබල ගන්වන්න
රටවල් 7ක් පුරා ක්ෂණික අසීමිත Dedicated IPv4 සහ Static ISP ප්රොක්සි.
Node.js ප්රොක්සි මිලදී ගන්න