From 468fc48c80f8709f42839c443f5e77bea44693c7 Mon Sep 17 00:00:00 2001 From: senap Date: Wed, 16 Jul 2014 15:44:25 +0700 Subject: [PATCH 01/13] add files --- lib/antigate.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/antigate.rb b/lib/antigate.rb index 52220c2..0732739 100644 --- a/lib/antigate.rb +++ b/lib/antigate.rb @@ -29,10 +29,10 @@ def initialize(key) @domain = "antigate.com" end - def recognize(url, ext) + def recognize(captcha_file, ext) added = nil loop do - added = add(url, ext) + added = add(captcha_file, ext) next if added.nil? if added.include? 'ERROR_NO_SLOT_AVAILABLE' sleep(1) @@ -61,13 +61,17 @@ def recognize(url, ext) end end - def add(url, ext) - uri = URI.parse(url) - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = (uri.port == 443) - request = Net::HTTP::Get.new(uri.request_uri) - response = http.request(request) - captcha = response.body + def add(captcha_file, ext) + if captcha_file.include?("http") + uri = URI.parse(url) + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = (uri.port == 443) + request = Net::HTTP::Get.new(uri.request_uri) + response = http.request(request) + captcha = response.body + else + captcha = File.read("#{captcha_file}.#{ext}") + end if captcha params = { 'method' => 'base64', From 0157eaa3b136e97c5dfabbbc0c227f6e108165f5 Mon Sep 17 00:00:00 2001 From: SeNaP Date: Wed, 16 Jul 2014 15:48:07 +0700 Subject: [PATCH 02/13] Update README.markdown --- README.markdown | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 5ccb1e9..05fbb58 100644 --- a/README.markdown +++ b/README.markdown @@ -19,12 +19,16 @@ Gem recognizes CAPTCHA by means Antigate. puts recognized[0] # ID recognized CAPTCHA puts recognized[1] # Text CAPTCHA -#### Example +#### From remote file captcha = Antigate.wrapper('660aaf58948bae3fa81362ef71b9ebcc') captcha.phrase = 1 recognized = captcha.recognize('http://www.google.com/recaptcha/api/image?c=03AHJ_Vuu-Kun_wMo4M8JiWA87K6awfoiUxJCUF9KkQq3tCfyxjYELhHcsIJrcJ_qgqIQQsBw5vWAkpHBqP4VEHv1nwtoAnD5uZvwzHknOFyID4OrX0_6q8QXQ5TwkRn7qBxdt3QdX6D8NvPcFHFHzmEhu1yCJJQfTwQ', 'jpg') puts recognized[1] - +#### From local file + captcha = Antigate.wrapper('660aaf58948bae3fa81362ef71b9ebcc') + captcha.phrase = 1 + recognized = captcha.recognize('captcha', 'jpg') + puts recognized[1] ### Get balance puts Antigate.balance(KEY) @@ -32,4 +36,4 @@ Gem recognizes CAPTCHA by means Antigate. puts Antigate.balance('660aaf58948bae3fa81362ef71b9ebcc') [1]: http://antigate.com/ -[2]: http://antigate.com/index.php?action=regscreen \ No newline at end of file +[2]: http://antigate.com/index.php?action=regscreen From 8f5f58b25a2ea2426ae6f16d23c467c4af005766 Mon Sep 17 00:00:00 2001 From: SeNaP Date: Wed, 16 Jul 2014 18:06:12 +0700 Subject: [PATCH 03/13] Update README.markdown --- README.markdown | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 05fbb58..ce6a161 100644 --- a/README.markdown +++ b/README.markdown @@ -3,9 +3,12 @@ Gem recognizes CAPTCHA by means Antigate. [Registration Antigate account][2] +## Gemfile Install + gem 'antigate', :github => 'SeNaP/antigate' ## Install - gem install antigate - + git clone https://github.com/SeNaP/antigate.git + cd antigate && gem build antigate + sudo gem install antigate.gem ## Usage ### Recognize captcha captcha = Antigate.wrapper(KEY) From 4f1fe1201438a86e85940b35eda3f8eccff54b74 Mon Sep 17 00:00:00 2001 From: SeNaP Date: Wed, 16 Jul 2014 18:06:39 +0700 Subject: [PATCH 04/13] Update README.markdown --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index ce6a161..0f6fa03 100644 --- a/README.markdown +++ b/README.markdown @@ -3,9 +3,9 @@ Gem recognizes CAPTCHA by means Antigate. [Registration Antigate account][2] -## Gemfile Install +### Gemfile Install gem 'antigate', :github => 'SeNaP/antigate' -## Install +### Install git clone https://github.com/SeNaP/antigate.git cd antigate && gem build antigate sudo gem install antigate.gem From d3cb86a86179e3b2fe537fadaaa9bd5f085ed73a Mon Sep 17 00:00:00 2001 From: SeNaP Date: Wed, 16 Jul 2014 18:06:55 +0700 Subject: [PATCH 05/13] Update README.markdown --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 0f6fa03..b00cd5a 100644 --- a/README.markdown +++ b/README.markdown @@ -3,9 +3,9 @@ Gem recognizes CAPTCHA by means Antigate. [Registration Antigate account][2] -### Gemfile Install +#### Gemfile Install gem 'antigate', :github => 'SeNaP/antigate' -### Install +#### Install git clone https://github.com/SeNaP/antigate.git cd antigate && gem build antigate sudo gem install antigate.gem From c67a6eadb04404b6fe8287a8f87201fe70d14d19 Mon Sep 17 00:00:00 2001 From: SeNaP Date: Wed, 16 Jul 2014 18:08:39 +0700 Subject: [PATCH 06/13] Update README.markdown --- README.markdown | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index b00cd5a..8f05d72 100644 --- a/README.markdown +++ b/README.markdown @@ -3,9 +3,10 @@ Gem recognizes CAPTCHA by means Antigate. [Registration Antigate account][2] -#### Gemfile Install +## Install +### Gemfile Install gem 'antigate', :github => 'SeNaP/antigate' -#### Install +### Local Install git clone https://github.com/SeNaP/antigate.git cd antigate && gem build antigate sudo gem install antigate.gem From 19bb481f047d5fa2401c50c9c85a84c3453f8b67 Mon Sep 17 00:00:00 2001 From: SeNaP Date: Wed, 16 Jul 2014 18:09:28 +0700 Subject: [PATCH 07/13] Update README.markdown --- README.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 8f05d72..5ae77a9 100644 --- a/README.markdown +++ b/README.markdown @@ -5,11 +5,11 @@ Gem recognizes CAPTCHA by means Antigate. ## Install ### Gemfile Install - gem 'antigate', :github => 'SeNaP/antigate' + gem 'antigate', :github => 'SeNaP/antigate' ### Local Install - git clone https://github.com/SeNaP/antigate.git - cd antigate && gem build antigate - sudo gem install antigate.gem + git clone https://github.com/SeNaP/antigate.git + cd antigate && gem build antigate + sudo gem install antigate.gem ## Usage ### Recognize captcha captcha = Antigate.wrapper(KEY) From 3e6fd0d64f303ef556847baddc38efece202e984 Mon Sep 17 00:00:00 2001 From: SeNaP Date: Mon, 21 Jul 2014 13:47:13 +0700 Subject: [PATCH 08/13] Update version.rb --- lib/antigate/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/antigate/version.rb b/lib/antigate/version.rb index 23bd9f9..24d8482 100644 --- a/lib/antigate/version.rb +++ b/lib/antigate/version.rb @@ -1,3 +1,3 @@ module Antigate - VERSION = "0.0.2" + VERSION = "0.0.3" end From fb122a40342bbb721f34a7c6c8e770ab72438dde Mon Sep 17 00:00:00 2001 From: SeNaP Date: Mon, 21 Jul 2014 13:54:36 +0700 Subject: [PATCH 09/13] Update antigate.gemspec --- antigate.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/antigate.gemspec b/antigate.gemspec index d959bb1..c7a47e9 100644 --- a/antigate.gemspec +++ b/antigate.gemspec @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) -require "antigate/version" +require "lib/antigate/version" Gem::Specification.new do |s| s.name = "antigate" From fb679edd0b877e6542b5853e1c216ff9a3bfcf2f Mon Sep 17 00:00:00 2001 From: SeNaP Date: Mon, 21 Jul 2014 13:55:30 +0700 Subject: [PATCH 10/13] Update antigate.gemspec --- antigate.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/antigate.gemspec b/antigate.gemspec index c7a47e9..d959bb1 100644 --- a/antigate.gemspec +++ b/antigate.gemspec @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) -require "lib/antigate/version" +require "antigate/version" Gem::Specification.new do |s| s.name = "antigate" From d9af5578daa568eaefc7d7a81fdfe5f5b1391174 Mon Sep 17 00:00:00 2001 From: SeNaP Date: Mon, 21 Jul 2014 15:18:40 +0700 Subject: [PATCH 11/13] Update antigate.rb --- lib/antigate.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/antigate.rb b/lib/antigate.rb index 0732739..d87c1ac 100644 --- a/lib/antigate.rb +++ b/lib/antigate.rb @@ -1,5 +1,3 @@ -require "antigate/version" - module Antigate require 'net/http' require 'uri' From 2c4efb8690aabc16e865161dd693623cc5b7e111 Mon Sep 17 00:00:00 2001 From: SeNaP Date: Tue, 31 Jan 2017 10:42:54 +0700 Subject: [PATCH 12/13] captcha_file --- lib/antigate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/antigate.rb b/lib/antigate.rb index d87c1ac..352913d 100644 --- a/lib/antigate.rb +++ b/lib/antigate.rb @@ -61,7 +61,7 @@ def recognize(captcha_file, ext) def add(captcha_file, ext) if captcha_file.include?("http") - uri = URI.parse(url) + uri = URI.parse(captcha_file) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = (uri.port == 443) request = Net::HTTP::Get.new(uri.request_uri) From 19303aedc9ff86b402621cafc536e294e1c5d6c2 Mon Sep 17 00:00:00 2001 From: SeNaP Date: Tue, 31 Jan 2017 10:43:36 +0700 Subject: [PATCH 13/13] 0.0.4 --- lib/antigate/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/antigate/version.rb b/lib/antigate/version.rb index 24d8482..1fce7aa 100644 --- a/lib/antigate/version.rb +++ b/lib/antigate/version.rb @@ -1,3 +1,3 @@ module Antigate - VERSION = "0.0.3" + VERSION = "0.0.4" end