npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

auto-proxy

v1.0.21

Published

Never care about proxylists again!

Downloads

6

Readme

auto-proxy

NPM NPM

Never care about proxies again!

AutoProxy is a nodejs module that ships with web-scrapers out-of-the-box! That means you don't have to spend hours goog'ling proxysites. Just fire up AutoProxy and let it search the proxies for you. However if you've still got one of these old-style IP:PORT lists on your 16MB flash-drive, AutoProxy can handle that too.

Installation

npm i --save auto-proxy

Usage

const AutoProxy = require('auto-proxy');

Just create a new instance using .new() and pass the path to it

// Parameters:
// 1st -> How many requests a proxy can handle before autoproxy swaps it
// 2nd -> Options
// 3rd -> Path to your proxylist
// 4th -> Whether to disable the crawler or not
AutoProxy.new(25, {}, '/path/to/proxy.list', false).then(function(proxy){
  //PROFIT!
});

Note: This list must be in this format:

IP:PORT
IP:PORT
...

Just want to check if your list works?

No problem either!

The "normal" API

The normal API is completely Promise/A+ based. If you don't like this you can use the __simple__ API.

.new(interval, options, localProxylist, disableCrawling)

Creates an auto-proxy instance

// The interval describes how many requests a proxy may handle before
// a new one will be used
//
// The options object takes as less or many options as you like, but you have to define it (empty object)
//
// Here you see how a full config looks like, and what the default options are
AutoProxy.new(25, {
  enableLogging: false, //Wether to interact with the user or not
  autoRefresh: false,   //If enabled auto-proxy will reload the proxies as soon as there are no more in the pool.
                        //Please note that this may take up to a few minutes depending on your internet speed.
                        //While debugging this may seem like you program is stuck if you disable $enableLogging
  
  reLoop: false         //After there are no more proxies in the pool, just start over.
                        //You'd have to call .refillProxies() to crawl for new proxies
  
  __simple__: {         // The __simple__ API. For usage scroll down :)
    reLoop: true        // Works like the reloop option of auto-proxy.
                        // To refill, you'd have to call .refillProxies() and __simple__.refresh() afterwards
  }
}).then(function(proxy) { //This proxy object is your instance
  ... // Use your instance
});

.refillProxies()

Loads new proxies from various proxylists

proxy.refillProxies().then(function(){
  // Proxies are now refilled.
  // Use them!
  ...
});

.forceNext()

Force-switch to the next proxy. Resets the interval counter

proxy.forceNext().then(function(){
  // Proxy is switched!
  // Use it!
  ...
});

.blockCurrent()

Blocks the current proxy, so that it won't be reLoop'ed or used again

proxy.blockCurrent().then(function(){
  // Proxy is blocked and switched!
  // Use it!
  ...
});

.getCurrent(ignoreUsage)

Get the current proxy

// Respects the proxy interval
proxy.getCurrent().then(function(ip) {
  console.log(`The ip is ${ip}`);
});

// Ignores the proxy interval
proxy.getCurrent(true).then(function(ip) {
  console.log(`The ip is ${ip}`);
});

.getPrefixedCurrent(ignoreUsage)

Works like .getCurrent() but prefixes the IP with http://.

The __simple__ API

The simple API is completely synchronous and does not refresh/re-scrape automatically.

.init()

Initializes the caches and prepares for usage

You should call this in the AutoProxy.new().then() callback.

.refresh()

This method will copy all proxies from the normal API into a seperate cache used only by __simple__.

You can clear this cache using .__simple__.resetCache()

.next()

Jumps to the next proxy and resets the interval

.get()

Returns the current proxy (repecting the interval)

.block()

Blocks the current proxy, so that it won't be reLoop'ed or used again

So how do i handle an empty proxy pool when i'm using the __simple__ API?

Glad you asked :)

The __simple__ API throws a ProxiesEmptyException when there are no more proxies.

Just catch it, load new proxies and refresh the cache. VOILA!

let ip = null;

try {
  ip = proxy.__simple__.get();
} catch (e) {
  proxy.refillProxies().then(function(){
    proxy.__simple__.refresh();
    ip = proxy.__simple__.get();
  });
}

I just want to check if my proxies work!

No problem!

AutoProxy.new(1, {}, '/path/to/list.txt', true).then(function(proxy) {
  require('fs').writeFileSync('checked_proxies.txt', JSON.stringify(proxy.proxyList));
});