Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

proxy-rotator-agent

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-rotator-agent

HTTP proxy rotator tunneling agent

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

proxy-rotator-agent

This agent rotates requests trought especified proxies

If 2 proxies are specified First request goes trought first proxy Second request goes trought seconde proxy Third request goes trought first proxy

for mikeal/request

const request = require('request');
const ProxyRotator = require('proxy-rotator-agent')

const agent = new ProxyRotator({
   proxies: [
     { host: '10.0.0.1', port: 3128, proxyAuth: 'pass', headers: { 'user-agent': 'nautilus' }},
     { host: '10.0.0.2', port: 4545, proxyAuth: 'proxy2pass', headers: { 'user-agent': 'firefox' }}
   ]
})

function optionalCallback(err, httpResponse, body) {
    if(err) return console.error(err);
    console.log(err, body);
}

request({
  uri: 'https://httpbin.org/ip',
  json: true,
  agent,
  }, 
  optionalCallback
)

request({
  uri: 'https://httpbin.org/ip',
  json: true,
  agent,
  }, 
  optionalCallback
)

Output

{
  ip: '10.0.0.1'
}
{
  ip: '10.0.0.2'
}

for native https request

const https = require('https');
const ProxyRotator = require('proxy-rotator-agent')

const agent = new ProxyRotator({
   proxies: [
     { host: '10.0.0.1', port: 3128, proxyAuth: 'pass', headers: { 'user-agent': 'nautilus' }},
     { host: '10.0.0.2', port: 4545, proxyAuth: 'proxy2pass', headers: { 'user-agent': 'firefox' }}
   ]
})
const options = {
    hostname: 'httpbin.org',
    port: 443,
    path: '/ip',
    agent,

};
// Make a request
function request(options) {
    const req = https.request(options);
    req.on('response', (res) => {
        res.on('data', (data) => {
            console.log(data.toString())
        });
    });
    req.on('error', (err) => {
        console.error(err);
    });
    req.end();
}

request(options)
request(options)

Output:

{
  "origin": "10.0.0.1"
}
{
  "origin": "10.0.0.2"
}

for axios

FAQs

Package last updated on 10 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc