Skip to content

kirillplatonov/proxy_manager

Repository files navigation

Ruby Proxy Manager

Gem Version Build Status Code Climate Coverage

Easy manage proxy in your parsers/web-bots.

Installation

Add this line to your application's Gemfile:

gem 'proxy_manager'

And then execute:

$ bundle

Or install it yourself as:

$ gem install proxy_manager

Usage

Load proxy list

From array (IP:PORT)

proxy = ProxyManager::Proxy.new(['127.0.0.1:80', '127.0.0.1:8080'])

or from file

proxy = ProxyManager::Proxy.new('proxies.txt')

File with proxy list (in this case proxies.txt) should be readable and writable. Example of proxies.txt content:

127.0.0.1:80
127.0.0.1:8080
...

Get proxy

There is two methods to get proxy.

First method return just next proxy, without any checking for availability:

proxy.get
# => ["127.0.0.1", 80]

Band method return only HTTP-available proxy. It's perfect if you don't realy confidency on actuallity of your proxy list:

proxy.get!
# => ["127.0.0.1", 8080]

You can also get for than one proxy per request by adding count for both methods like this:

proxy.get(2)
# => [["127.0.0.1", 80], ["127.0.0.1", 8080]]

proxy.get!(2)
# => [["127.0.0.1", 80], ["127.0.0.1", 8080]]

Proxies list

For display list of loaded proxies use list method:

proxy.list
# => [["127.0.0.1", 80], ["127.0.0.1", 8080]]

Checking proxy manually

You can also use class method for checking availability manually like this:

# by passing a string
ProxyManager::Proxy.connectable?('127.0.0.1:80')
# => false

# or by passing an array
ProxyManager::Proxy.connectable?('127.0.0.1', 80)
# => false

Please, don't forget to star ⭐ the repository if you like (and use) the library. This will let me know how many users it has and then how to proceed with further development :).

Documentation

http://rubydoc.info/gems/proxy_manager

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Ruby proxy manager. Gem for easy usage proxy in parser/web bots.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Languages