0.0
No commit activity in last 3 years
No release in over 3 years
Manages rotation of proxies using a queuing system and STOMP
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
~> 10.0
~> 3.1

Runtime

>= 2.7.3, ~> 2.7
>= 1.0.1, ~> 1.0
 Project Readme

ProxyService

A service class that rotates a list of proxies stored in a queue. The queueing system must support the STOMP protocol. Can be used with or without proxies. A queue name should be given and the queue should have a list of proxies in the format of { failures: 0, ip: '127.0.0.1', port: '80' }. The service uses this info to set the proxy of a mechanize agent. If an exception occurs in the block, the proxy's :failures count is incremented and it's put back in the queue to be used again. Once the :failures count exceeds the #failure_limit it will be removed from the queue.

Installation

Add this line to your application's Gemfile:

gem 'proxy_service'

And then execute:

$ bundle

Or install it yourself as:

$ gem install proxy_service

Usage

Configure the service, for example, in an initializer

ProxyService.configure do |config|
  config.proxies_enabled = true
  # only used when proxies enabled
  config.username = '...'  
  config.password = '...' 
  config.failure_limit = 3
  config.failure_codes = %w[503 403] # used to determine if the proxy has been blocked
end

And then use it in your app

ProxyService.new('queue_with_proxies').with_mechanize do |agent|
  agent.get('http://...')
end

Some config settings can be overwritten on initialize

ProxyService.new('queue_with_proxies', proxies_enabled: false)

Contributing

  1. Fork it ( https://github.com/ridiculous/proxy_service/fork )
  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 a new Pull Request