Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add local captha file #6

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Next Next commit
add files
SeNaP committed Jul 16, 2014
commit 468fc48c80f8709f42839c443f5e77bea44693c7
22 changes: 13 additions & 9 deletions lib/antigate.rb
Original file line number Diff line number Diff line change
@@ -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',