A proxy manager class designed to help limit the rate of your use of proxies.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


#Proxy Manager

ProxyManager is Ruby class useful for web bots / scrapers or any other http requests whereby you need to limit how frequently you use the same proxy. This stops sites from blocking / filtering your IP.

You can set your own delay which is time that you want to leave a proxy to "cool down".The ideal amount for depends on how tolerant the site your scraping is, so you'll have to work that out on your own.

Inspired by the ProxyManager in mattseh's python-web library, with a few additions / tweaks.


You can pass either a array of proxies to the class, or you can specify a file to load them from.

Proxies from array:

prox = ["","",""]

# Passing in a array, time delay is 15secs
manager = ProxyManager.new(prox, 15)

Proxies from file:

# Loading proxies directly from a file, delay is 20secs
manager = ProxyManager.from_proxy_file("path/to/proxy/file.txt", 20)

General examples of class methods

prox = ["","",""]
manager = ProxyManager.new(prox, 15)

# Grab a proxy
proxy = manager.available_proxy
#=> ""

# Check if there is a proxy available for use
#=> true

# Check how many proxies are available to use
#=> 2

# Grab two proxies
proxies = manager.available_proxies(2)
#=> ["",""]

# Check if there is a proxy available for use
#=> false