Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions lib/antigate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,35 @@ def recognize(url, ext)
return added
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
if captcha
params = {
'method' => 'base64',
'key' => @key,
'body' => Base64.encode64(captcha),
'ext' => ext,
'phrase' => @phrase,
'regsense' => @regsense,
'numeric' => @numeric,
'calc' => @calc,
'min_len' => @min_len,
'max_len' => @max_len
}
return Net::HTTP.post_form(URI("http://#{@domain}/in.php"), params).body rescue nil
end
end

def add(url, ext)
begin
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
rescue Exception => e
captcha = url
end

if captcha
params = {
'method' => 'base64',
'key' => @key,
'body' => Base64.encode64(captcha),
'ext' => ext,
'phrase' => @phrase,
'regsense' => @regsense,
'numeric' => @numeric,
'calc' => @calc,
'min_len' => @min_len,
'max_len' => @max_len
}
return Net::HTTP.post_form(URI("http://#{@domain}/in.php"), params).body rescue nil
end
end

def status(id)
return Net::HTTP.get(URI("http://#{@domain}/res.php?key=#{@key}&action=get&id=#{id}")) rescue nil
Expand Down