0.01
No release in over 3 years
Low commit activity in last 3 years
This is gem for easy usage proxy in your parsers/web-bots. It will manage your proxy list and check availability if you need it.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.3.2, ~> 1.3
>= 1.0.3, ~> 1.0
>= 4.2.8, ~> 4.2
>= 2.14.1, ~> 2.14
>= 0.9.7, ~> 0.9
>= 0.8.7.4, ~> 0.8
 Project Readme

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