Skip to content

Commit 0aa98a0

Browse files
NEW added captcha tasks
1 parent e1cb147 commit 0aa98a0

File tree

3 files changed

+109
-3
lines changed

3 files changed

+109
-3
lines changed

lib/imagetyperzapi.rb

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
HCAPTCHA_ENDPOINT = 'http://captchatypers.com/captchaapi/UploadHCaptchaUser.ashx'
2424
TIKTOK_ENDPOINT = 'http://captchatypers.com/captchaapi/UploadTikTokCaptchaUser.ashx'
2525
FUNCAPTCHA_ENDPOINT = 'http://captchatypers.com/captchaapi/UploadFunCaptcha.ashx'
26+
TASK_ENDPOINT = 'http://captchatypers.com/captchaapi/UploadCaptchaTask.ashx'
2627

2728
CAPTCHA_ENDPOINT_CONTENT_TOKEN = '/Forms/UploadFileAndGetTextNEWToken.ashx'
2829
CAPTCHA_ENDPOINT_URL_TOKEN = '/Forms/FileUploadAndGetTextCaptchaURLToken.ashx'
@@ -376,7 +377,7 @@ def submit_hcaptcha(d)
376377

377378
url = HCAPTCHA_ENDPOINT
378379

379-
# proxy
380+
# enterprise
380381
if d.key? 'HcaptchaEnterprise'
381382
d['HcaptchaEnterprise'] = JSON.generate(d['HcaptchaEnterprise'])
382383
end
@@ -442,6 +443,48 @@ def submit_funcaptcha(d)
442443
(JSON.parse response_text)[0]['CaptchaId']
443444
end
444445

446+
def submit_task(d)
447+
d['action'] = 'UPLOADCAPTCHA'
448+
d['captchatype'] = '16'
449+
# user or token ?
450+
if !@_username.empty?
451+
d["username"] = @_username
452+
d["password"] = @_password
453+
else
454+
d["token"] = @_access_token
455+
end
456+
457+
url = TASK_ENDPOINT
458+
459+
# affiliate id
460+
if @_affiliateid.to_s != '0'
461+
d["affiliateid"] = @_affiliateid.to_s
462+
end
463+
464+
# set variables from JSON to string
465+
if d.key? (:variables)
466+
d[:variables] = JSON.generate(d[:variables])
467+
end
468+
469+
# create url
470+
params = URI.encode_www_form(d)
471+
url = '%s?%s' % [url, params]
472+
473+
# make request
474+
uri = URI.parse(url)
475+
http = Net::HTTP.new(uri.host, uri.port)
476+
data = http.get(uri.request_uri)
477+
response_text = data.body
478+
479+
# check if error
480+
if response_text.include?("ERROR:")
481+
response_err = response_text.split('ERROR:')[1].strip() # get only the
482+
@_error = response_err
483+
raise @_error
484+
end
485+
(JSON.parse response_text)[0]['CaptchaId']
486+
end
487+
445488
def retrieve_response(captcha_id)
446489
# params
447490
data = {

readme.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,14 @@ Requires pageurl and sitekey
154154
d = {}
155155
d['pageurl'] = 'https://your-site.com'
156156
d['sitekey'] = '1c7062c7-cae6-4e12-96fb-303fbec7fe4f'
157-
# d['invisible'] = '1' # if invisible hcaptcha - optional
157+
# d['invisible'] = '1' # if invisible hcaptcha - optional
158+
159+
# extra parameters, useful for enterprise
160+
# submit userAgent from requests too, when this is used
161+
# d['HcaptchaEnterprise'] = {'rqdata': 'take value from web requests'}
162+
158163
# d['proxy'] = '126.45.34.53:123' # - HTTP proxy - optional
159164
# d['user_agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0' # optional
160-
captcha_id = ita.submit_hcaptcha d
161165
```
162166

163167
### Capy
@@ -202,6 +206,22 @@ d['surl'] = 'https://api.arkoselabs.com'
202206
captcha_id = ita.submit_funcaptcha d
203207
```
204208

209+
### Task
210+
211+
Requires template_name, page_url and usually variables
212+
213+
```ruby
214+
# task parameters
215+
d = {
216+
'template_name': 'Login test page',
217+
'pageurl': 'https://imagetyperz.net/automation/login',
218+
'variables': JSON.generate({"username": 'abc', "password": 'paZZW0rd'}),
219+
# 'proxy': '126.45.34.53:345', # or 126.45.34.53:123:joe:password
220+
# 'user_agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0', # optional
221+
}
222+
captcha_id = ita.submit_task d
223+
```
224+
205225
## Retrieve response
206226

207227
Regardless of the captcha type (and method) used in submission of the captcha, this method is used

task.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/ruby
2+
3+
# Imagetypers API test
4+
load "lib/imagetyperzapi.rb"
5+
6+
def test_api
7+
# grab token from https://imagetyperz.com
8+
access_token = "your_access_token"
9+
ita = ImageTyperzAPI.new(access_token)
10+
11+
# check account balance
12+
balance = ita.account_balance # get balance
13+
puts "Account balance: #{balance}" # print balance
14+
15+
# task parameters
16+
d = {
17+
'template_name': 'Login test page',
18+
'pageurl': 'https://imagetyperz.net/automation/login',
19+
'variables': {"username": 'abc', "password": 'paZZW0rd'},
20+
# 'proxy': '126.45.34.53:345', # or 126.45.34.53:123:joe:password
21+
# 'user_agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0', # optional
22+
}
23+
24+
captcha_id = ita.submit_task d
25+
# submit image captcha, and check for solution
26+
puts "Waiting for captcha to be solved..."
27+
response = nil
28+
while response == nil
29+
sleep 10
30+
response = ita.retrieve_response captcha_id
31+
end
32+
puts "Response: #{response}"
33+
end
34+
35+
def main
36+
begin
37+
test_api
38+
rescue => details
39+
puts "[!] Error occured: #{details}"
40+
end
41+
end
42+
43+
main

0 commit comments

Comments
 (0)