DeathByCaptcha is a Ruby API for acessing the http://www.deathbycaptcha.com services.
It supports HTTP and socket-based connections, with the latter being recommended for having faster responses and overall better performance.
When using socket connections, make sure that outgoing TCP traffic to api.deathbycaptcha.com to the ports range in 8123-8130 is not blocked by your firewall.
The API is thread-safe, which means it is perfectly fine to share a client instance between multiple threads.
You can install the latest DeathByCaptcha gem with:
gem install deathbycaptcha
You can add it to your Gemfile:
gem 'deathbycaptcha'
require 'deathbycaptcha'
client = DeathByCaptcha.http_client('myusername', 'mypassword')
require 'deathbycaptcha'
client = DeathByCaptcha.socket_client('myusername', 'mypassword')
client.config.is_verbose = true
response = client.decode 'http://www.phpcaptcha.org/securimage/securimage_show.php'
puts "captcha id: #{response['captcha']}, solution: #{response['text']}, is_correct: #{response['is_correct']}}"
response = client.decode 'path/to/my/captcha/file'
puts "captcha id: #{response['captcha']}, solution: #{response['text']}, is_correct: #{response['is_correct']}}"
file = File.open('path/to/my/captcha/file', 'r')
response = client.decode file
puts "captcha id: #{response['captcha']}, solution: #{response['text']}, is_correct: #{response['is_correct']}}"
raw_content = File.open('path/to/my/captcha/file', 'r').read
response = client.decode(raw_content, :is_raw_content => true)
puts "captcha id: #{response['captcha']}, solution: #{response['text']}, is_correct: #{response['is_correct']}}"
puts client.get_captcha('130920620')['text'] # where 130920620 is the captcha id
puts client.get_user
- Rafael Barbolo Lopes (http://github.com/barbolo)
- Rafael Ivan Garcia (http://github.com/rafaelivan)
MIT License. Copyright (C) 2011 by Infosimples. http://www.infosimples.com.br