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

url and string fo def add #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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