proxyratemanager
ES6 JS classes for http/https Proxy Requests and IP rate limiting
Installation
npm install proxyratemanager --save
Usage
This is a module to facilitate proxying requests while staying within specified rate limits per action.
NOTE: This module heavily relies on AdvancedRequest. Good understanding of it is pretty important to use this.
Main features:
- Automatically launch tor and change exit node
- Specification of multiple circuits through proxies or tor
- Automatic circuit "health" management to help avoid circuits during their downtime
- Specify actions to be limited by name per IP per unit time
- Specify pool of proxies to be randomly or specifically used
Example setup
const ProxyRateManager AdvancedProxiedRequest = ; let proxyRateManager = EXTERNAL_IP_CHECK_URL: `https://www.myexternalip.com/raw`; let oneDayInMs = 1000 * 60 * 60 * 24;proxyRateManager;proxyRateManager; await proxyRateManager; // unnamed socks5h proxies (in proxy pool)proxyRateManager;
Create a ProxyClient to send requests using the pool for this manager
let proxyClient = proxyRateManager; // Send a request through this proxyClientlet req = url: `http://example.com/api/v1/dosomething` method: 'GET' name: "apirequest1" // used to signal an action completed reqArgs: proxyClient: proxyClient // specify this client to use ; // Call before running request on for this action name of "apirequest1"await proxyClient; let jsonData = await req; // run the request (through the proxy) if jsonDatasomething_is_wrong_with_request_results // call .forceIPChangeImmediately() to have your exit IP randomly changed (guaranteed to change) await proxyClient; else // report action completed for counters to update proxyClient;
Get details about current circuit for this client object
let exitIP = proxyClient; // get the current external/exit IP from the clientlet circuitIdentifier = proxyClientcircuit; // get the information its the circuit in uselet health = proxyClientcircuit; // All proxies are periodically polled to check their health/IPs console;
A lot goes into this module. Reading the code is useful to understand more of how it works.