deathbycaptcha 5.0.5 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c08aa72d280a8c0849735ba8b6e69cd755f51fee
4
- data.tar.gz: c3e83f7d34fe105668c9eb85a5d5e0269dbec77c
3
+ metadata.gz: 0ade8e91dabaff38c45364e41cc0e90eb667dc3b
4
+ data.tar.gz: 2563cc60295125efac5e573fa478aa57b7f6ddc3
5
5
  SHA512:
6
- metadata.gz: 03b9e78a451f67074d94808132ce7de0982fc2a6d1ce2bc7011e4589bcf6f31d91e63f0a55adea4401bbe672ef636e29b933fbb5c666d2fde4c446bc56a3c1a1
7
- data.tar.gz: 70ba966a1fdfae5748b24bdb41d7c0ae73dfb1b058b0c5c115e97b5ec841f6c91ff631b17fec862599092a3a50d9bb0cc619e82142a27b827e7b0d997276d7a5
6
+ metadata.gz: 5ef6a321ccd6c67cff5afed7048c1c8ec627b14baaa2e40c210183e371cc2c681a280c6fedfc78f927cb00b62fd93c8b8d67157bd955441fc61e2d48d2865554
7
+ data.tar.gz: bc31af5d0705e589468c08bae270ddaa85b03a9f9fa7bf7b991d70f08bb2d421d98719697bd7861d86552a48b82ca35c8a76d00e96e28e90dce28597231ee9e4
data/README.md CHANGED
@@ -182,6 +182,55 @@ something like:
182
182
  [1, 9]
183
183
  ```
184
184
 
185
+ ## New Recaptcha by Token API
186
+
187
+ > It's currently available only with the :http client.
188
+
189
+ To solve captchas similar to
190
+ [reCAPTCHA v2](https://support.google.com/recaptcha/?hl=en#6262736), you can also use
191
+ **Token API**
192
+
193
+ Please, read the oficial documentation at
194
+ http://deathbycaptcha.com/user/api/newtokenrecaptcha
195
+
196
+ ### Using the Token API
197
+
198
+ ```ruby
199
+ # Read above all the instructions on how to solve a captcha.
200
+ captcha = client.decode!(type: 4, token_params: {
201
+ # optional proxy if needed and server verifies
202
+ #proxy: "http://127.0.0.1:3128",
203
+ #proxytype: "HTTP",
204
+ googlekey: "6Ld2sf4SAAAAAKSgzs0Q13IZhY02Pyo31S2jgOB5",
205
+ pageurl: "https://patrickhlauke.github.io/recaptcha/"
206
+ })
207
+ ```
208
+
209
+ You should specify arguments with *type = 4* and an all token params required by DBC API
210
+
211
+ The response will be a text (token), which you can access with **text** or **token** method.
212
+
213
+ ```ruby
214
+ # captcha.text
215
+ "03AOPBWq_RPO2vLzyk0h8gH0cA2X4v3tpYCPZR6Y4yxKy1s3Eo7CHZRQntxrd
216
+ saD2H0e6S3547xi1FlqJB4rob46J0-wfZMj6YpyVa0WGCfpWzBWcLn7tO_EYs
217
+ vEC_3kfLNINWa5LnKrnJTDXTOz-JuCKvEXx0EQqzb0OU4z2np4uyu79lc_Ndv
218
+ L0IRFc3Cslu6UFV04CIfqXJBWCE5MY0Ag918r14b43ZdpwHSaVVrUqzCQMCyb
219
+ cGq0yxLQf9eSexFiAWmcWLI5nVNA81meTXhQlyCn5bbbI2IMSEErDqceZjf1m
220
+ X3M67BhIb4"
221
+
222
+ # captcha.token
223
+ "03AOPBWq_RPO2vLzyk0h8gH0cA2X4v3tpYCPZR6Y4yxKy1s3Eo7CHZRQntxrd
224
+ saD2H0e6S3547xi1FlqJB4rob46J0-wfZMj6YpyVa0WGCfpWzBWcLn7tO_EYs
225
+ vEC_3kfLNINWa5LnKrnJTDXTOz-JuCKvEXx0EQqzb0OU4z2np4uyu79lc_Ndv
226
+ L0IRFc3Cslu6UFV04CIfqXJBWCE5MY0Ag918r14b43ZdpwHSaVVrUqzCQMCyb
227
+ cGq0yxLQf9eSexFiAWmcWLI5nVNA81meTXhQlyCn5bbbI2IMSEErDqceZjf1m
228
+ X3M67BhIb4"
229
+ ```
230
+
231
+ > Those captchas sometimes took more than 60 seconds to solve
232
+ > So consider increasing the client's *timeout*
233
+
185
234
  ## Notes
186
235
 
187
236
  #### Thread-safety
@@ -238,14 +287,6 @@ This gem has been tested on the following versions of Ruby:
238
287
  * MRI 2.0.0
239
288
  * MRI 1.9.3
240
289
 
241
- # Maintainers
242
-
243
- * [Débora Setton Fernandes](http://github.com/deborasetton)
244
- * [Marcelo Mita](http://github.com/marcelomita)
245
- * [Rafael Barbolo](http://github.com/barbolo)
246
- * [Rafael Ivan Garcia](http://github.com/rafaelivan)
247
-
248
-
249
290
  ## Contributing
250
291
 
251
292
  1. Fork it ( https://github.com/infosimples/deathbycaptcha/fork )
@@ -86,8 +86,12 @@ module DeathByCaptcha
86
86
  def decode!(options = {})
87
87
  started_at = Time.now
88
88
 
89
- raw64 = load_captcha(options)
90
- raise DeathByCaptcha::InvalidCaptcha if raw64.to_s.empty?
89
+ # don't load image data for Token API
90
+ raw64 = nil
91
+ unless options[:type] == 4
92
+ raw64 = load_captcha(options)
93
+ raise DeathByCaptcha::InvalidCaptcha if raw64.to_s.empty?
94
+ end
91
95
 
92
96
  decoded_captcha = self.upload(options.merge(raw64: raw64))
93
97
 
@@ -61,6 +61,12 @@ module DeathByCaptcha
61
61
 
62
62
  payload[:banner] = "base64:#{banner64}"
63
63
  payload[:banner_text] = options[:banner_text].to_s
64
+
65
+ elsif options[:type].to_i == 4
66
+ payload = {
67
+ type: 4,
68
+ token_params: options[:token_params].to_json,
69
+ }
64
70
  end
65
71
 
66
72
  response = perform('captcha', :post_multipart, payload)
@@ -24,5 +24,6 @@ module DeathByCaptcha
24
24
  end
25
25
  alias_method :coordinates, :parsed_text
26
26
  alias_method :indexes, :parsed_text
27
+ alias_method :token, :text
27
28
  end
28
29
  end
@@ -1,4 +1,4 @@
1
1
  module DeathByCaptcha
2
- VERSION = "5.0.5"
2
+ VERSION = "5.1.0"
3
3
  API_VERSION = "DBC/Ruby v#{VERSION}"
4
4
  end
@@ -6,6 +6,12 @@ path2 = './captchas/2.jpg' # path of the captcha (Coordinates API)
6
6
  path3_grid = './captchas/3-grid.jpg' # path of the grid (Image Group API)
7
7
  path3_banner = './captchas/3-banner.jpg' # path of the grid (Image Group API)
8
8
  banner_text3 = 'Click all images with bananas'
9
+ token_params = {
10
+ #proxy: "http://127.0.0.1:3128",
11
+ #proxytype: "HTTP",
12
+ googlekey: "6Ld2sf4SAAAAAKSgzs0Q13IZhY02Pyo31S2jgOB5",
13
+ pageurl: "https://patrickhlauke.github.io/recaptcha/"
14
+ }
9
15
 
10
16
  describe 'Solving an image based captcha' do
11
17
  before(:all) { @client = DeathByCaptcha.new(username, password, :http) }
@@ -53,4 +59,22 @@ describe 'Solving an image based captcha' do
53
59
  it { expect(@captcha.id).to eq(@captcha.captcha) }
54
60
  end
55
61
  end
62
+
63
+ context 'Token API' do
64
+ describe '#decode!' do
65
+ before(:all) do
66
+ @captcha = @client.decode!(
67
+ type: 4,
68
+ token_params: token_params,
69
+ )
70
+ end
71
+ it { expect(@captcha).to be_a(DeathByCaptcha::Captcha) }
72
+ it { expect(@captcha.text).to eq(@captcha.token) }
73
+ it { expect(@captcha.token).to match(/\A"?\S+"?\Z/) }
74
+ it { expect(@captcha.token.size).to be > 30 }
75
+ it { expect(@captcha.is_correct).to be true }
76
+ it { expect(@captcha.id).to be > 0 }
77
+ it { expect(@captcha.id).to eq(@captcha.captcha) }
78
+ end
79
+ end
56
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deathbycaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.5
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Barbolo, Rafael Ivan Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2017-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.4.3
110
+ rubygems_version: 2.5.1
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Ruby API for DeathByCaptcha (Captcha Solver as a Service)