WARUM NODE.JS + PROXY POLAND
Node.js ist die bevorzugte Laufzeitumgebung für serverseitige Automatisierung und API-Scraping. Durch die Nutzung von 4G-Mobilproxys von Proxy Poland erhalten Sie echte Carrier-IPs.
EINRICHTUNGSANLEITUNG
HTTP-Bibliotheken installieren
Installieren Sie axios oder verwenden Sie das eingebaute https-Modul:
npm install axios # For SOCKS5 support: npm install socks-proxy-agent # For HTTPS proxy: npm install https-proxy-agent
Proxy-Zugangsdaten holen
Registrieren Sie sich auf proxypoland.com und erhalten Sie IP, Port, Benutzername und Passwort.
HTTP-Proxy mit Axios konfigurieren
Axios-Requests über den Proxy leiten:
const axios = require('axios');
const response = await axios.get('https://httpbin.org/ip', {
proxy: {
host: 'proxy-ip',
port: 8080,
auth: {
username: 'your-username',
password: 'your-password',
},
protocol: 'http',
},
});
console.log(response.data);
// Should show Polish mobile IPMit nativem https-Modul konfigurieren
Node.js eingebautes https mit SOCKS5-Agent verwenden:
const { SocksProxyAgent } = require('socks-proxy-agent');
const https = require('https');
const agent = new SocksProxyAgent(
'socks5://username:password@proxy-ip:port'
);
const options = {
hostname: 'httpbin.org',
path: '/ip',
agent,
};
https.get(options, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => console.log(JSON.parse(data)));
});Mit node-fetch verwenden
node-fetch mit Proxy-Agent konfigurieren:
const fetch = require('node-fetch');
const { HttpsProxyAgent } = require('https-proxy-agent');
const agent = new HttpsProxyAgent(
'http://username:password@proxy-ip:port'
);
const response = await fetch('https://httpbin.org/ip', { agent });
const data = await response.json();
console.log(data);IP-Rotation hinzufügen
IP zwischen Scraping-Sitzungen rotieren:
const axios = require('axios');
async function rotateIP() {
const response = await axios.get(
`http://proxy-ip:port/rotate`,
{ auth: { username: 'user', password: 'pass' } }
);
console.log('New IP:', response.data);
return response.data;
}
// Rotate between scraping tasks
await rotateIP();
const result = await axios.get('https://target-site.com', { proxy: proxyConfig });IP überprüfen
Überprüfen, dass Anfragen über den Proxy geroutet werden:
const axios = require('axios');
const response = await axios.get('https://httpbin.org/ip', {
proxy: {
host: 'proxy-ip',
port: 8080,
auth: { username: 'user', password: 'pass' },
},
});
console.log(response.data.origin);
// Should show Polish mobile carrier IPPROFI-TIPPS
https-proxy-agent oder socks-proxy-agent für Kompatibilität verwenden
Retry-Logik mit p-retry oder exponentiellem Backoff implementieren
async/await mit Promise.all für parallele Anfragen nutzen
IPs zwischen Scraping-Batches rotieren, um Sperren zu vermeiden
Realistische User-Agent-Header mit dem user-agents npm-Paket setzen
FUNKTIONIERT HERVORRAGEND FÜR
FAQ
Welche Node.js HTTP-Bibliothek funktioniert am besten mit Mobilproxys?+
Axios ist die beliebteste Wahl aufgrund der einfachen Proxy-Konfiguration. Für native Nutzung funktionieren https-proxy-agent und socks-proxy-agent mit eingebauten Node.js-Modulen.
Wie verwende ich SOCKS5-Proxys in Node.js?+
socks-proxy-agent installieren und als agent-Parameter übergeben. Proxy-URL-Format: socks5://user:pass@host:port.
Wie verwalte ich Proxy-Authentifizierung in Node.js?+
Für Axios das Proxy-Konfigurationsobjekt mit auth.username und auth.password setzen. Für agent-basierte Clients Zugangsdaten in die Proxy-URL einbetten.
Kann ich diese Proxys mit Playwright oder Puppeteer verwenden?+
Ja. --proxy-server=socks5://host:port als Launch-Argument übergeben, dann page.authenticate() für die Zugangsdaten verwenden.
Wie implementiere ich IP-Rotation in Node.js?+
Den Rotations-Endpunkt (GET /rotate am Proxy) zwischen Scraping-Aufgaben aufrufen. Die API gibt die neue IP zurück.