two_captcha 1.7.0 → 1.9.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 +4 -4
- data/README.md +131 -185
- data/lib/two_captcha/client.rb +51 -6
- data/lib/two_captcha/version.rb +1 -1
- data/two_captcha.gemspec +2 -2
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9ebd0f5784ffc3348f29f9abcd82e31f6298d6dc959557c204b41aeb19aae31
|
4
|
+
data.tar.gz: 4e5f0abecd976ea5cd4385bfffda6469a3dd8ba2b79f32bf81299488b9b39571
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 349f83ce8ce70a30289fac68c9b171bd6e256b189435d5a6802179551ef3e536baf342d9d02e541ffe9c469ca0c3ca86b6ac9f3ab5d96a57a4b4116727d78bee
|
7
|
+
data.tar.gz: acfc725708ace49701cacf0dd465db438d3a3749b76d3c85f7691b828f201728094eeb6ec43db424e654e2a364118586c18655a65d0f24378d112b55fe66d51f
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
Developed by [Infosimples](https://infosimples.com).
|
2
|
-
|
3
1
|
# TwoCaptcha
|
4
2
|
|
5
|
-
TwoCaptcha is a Ruby API for 2Captcha - [2Captcha.com](http://2captcha.com/?from=1025109)
|
3
|
+
TwoCaptcha is a Ruby API for 2Captcha - [2Captcha.com](http://2captcha.com/?from=1025109)
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -14,264 +12,212 @@ gem 'two_captcha'
|
|
14
12
|
|
15
13
|
And then execute:
|
16
14
|
|
17
|
-
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
````
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
|
21
|
+
```bash
|
22
|
+
$ gem install two_captcha
|
23
|
+
````
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
1.
|
26
|
-
|
27
|
-
```ruby
|
28
|
-
# Create a client
|
29
|
-
client = TwoCaptcha.new('my_captcha_key')
|
30
|
-
```
|
31
|
-
|
32
|
-
2. **Solve a captcha**
|
33
|
-
|
34
|
-
There are two methods available: **decode** and **decode!**
|
35
|
-
* **decode** doesn't raise exceptions.
|
36
|
-
* **decode!** may raise a *TwoCaptcha::Error* if something goes wrong.
|
37
|
-
|
38
|
-
If the solution is not available, an empty captcha object will be returned.
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
captcha = client.decode!(url: 'http://bit.ly/1xXZcKo')
|
42
|
-
captcha.text # Solution of the captcha
|
43
|
-
captcha.id # Numeric ID of the captcha solved by TwoCaptcha
|
44
|
-
```
|
45
|
-
|
46
|
-
You can also specify *path*, *file*, *raw* and *raw64* when decoding an image.
|
27
|
+
### 1. Create a client
|
47
28
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
client.decode(file: File.open('path/to/my/captcha/file', 'rb'))
|
52
|
-
|
53
|
-
client.decode(raw: File.open('path/to/my/captcha/file', 'rb').read)
|
54
|
-
|
55
|
-
client.decode(raw64: Base64.encode64(File.open('path/to/my/captcha/file', 'rb').read))
|
56
|
-
```
|
57
|
-
|
58
|
-
> Internally, the gem will always convert the image to raw64 (binary base64 encoded).
|
59
|
-
|
60
|
-
You may also specify any POST parameters specified at
|
61
|
-
https://2captcha.com/setting.
|
62
|
-
|
63
|
-
3. **Retrieve a previously solved captcha**
|
64
|
-
|
65
|
-
```ruby
|
66
|
-
captcha = client.captcha('130920620') # with 130920620 as the captcha id
|
67
|
-
```
|
68
|
-
|
69
|
-
4. **Report incorrectly (for refund) or correctly (useful for reCAPTCHA v3) solved captcha**
|
70
|
-
|
71
|
-
```ruby
|
72
|
-
client.report!('130920620', 'reportbad') # with 130920620 as the captcha id
|
73
|
-
# return true if successfully reported
|
74
|
-
|
75
|
-
client.report!('256892751', 'reportgood') # with 256892751 as the captcha id
|
76
|
-
# return true if successfully reported
|
77
|
-
```
|
29
|
+
```ruby
|
30
|
+
client = TwoCaptcha.new('my_key')
|
31
|
+
```
|
78
32
|
|
79
|
-
|
33
|
+
### 2. Solve a CAPTCHA
|
80
34
|
|
81
|
-
|
35
|
+
There are two types of methods available: `decode` and `decode!`:
|
82
36
|
|
83
|
-
|
84
|
-
|
85
|
-
# return a Float balance in USD.
|
86
|
-
```
|
37
|
+
- `decode` does not raise exceptions.
|
38
|
+
- `decode!` may raise a `TwoCaptcha::Error` if something goes wrong.
|
87
39
|
|
88
|
-
|
40
|
+
If the solution is not available, an empty solution object will be returned.
|
89
41
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
42
|
+
```ruby
|
43
|
+
captcha = client.decode_image!(url: 'http://bit.ly/1xXZcKo')
|
44
|
+
captcha.text # CAPTCHA solution
|
45
|
+
captcha.id # CAPTCHA numeric id
|
46
|
+
```
|
94
47
|
|
95
|
-
|
48
|
+
#### Image CAPTCHA
|
96
49
|
|
97
|
-
|
98
|
-
client.load
|
99
|
-
# return an XML string with the current service load.
|
100
|
-
```
|
50
|
+
You can specify `file`, `path`, `raw`, `raw64` and `url` when decoding an image.
|
101
51
|
|
102
|
-
|
52
|
+
```ruby
|
53
|
+
client.decode_image!(file: File.open('path/to/my/captcha/file', 'rb'))
|
54
|
+
client.decode_image!(path: 'path/to/my/captcha/file')
|
55
|
+
client.decode_image!(raw: File.open('path/to/my/captcha/file', 'rb').read)
|
56
|
+
client.decode_image!(raw64: Base64.encode64(File.open('path/to/my/captcha/file', 'rb').read))
|
57
|
+
client.decode_image!(url: 'http://bit.ly/1xXZcKo')
|
58
|
+
```
|
103
59
|
|
104
|
-
|
105
|
-
[reCAPTCHA v2](https://support.google.com/recaptcha/?hl=en#6262736).
|
60
|
+
You may also specify any POST parameters specified at https://2captcha.com/setting.
|
106
61
|
|
107
|
-
|
62
|
+
#### reCAPTCHA v2
|
108
63
|
|
109
|
-
|
110
|
-
|
64
|
+
```ruby
|
65
|
+
captcha = client.decode_recaptcha_v2!(
|
66
|
+
googlekey: 'xyz',
|
67
|
+
pageurl: 'http://example.com/example=1',
|
68
|
+
)
|
111
69
|
|
112
|
-
|
113
|
-
for more information.
|
70
|
+
# The response will be a text (token), which you can access with the `text` method.
|
114
71
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
pageurl: 'http://example.com/example=1'
|
119
|
-
}
|
72
|
+
captcha.text
|
73
|
+
"03AOPBWq_RPO2vLzyk0h8gH0cA2X4v3tpYCPZR6Y4yxKy1s3Eo7CHZRQntxrd..."
|
74
|
+
```
|
120
75
|
|
121
|
-
|
122
|
-
captcha.text # Solution of the captcha
|
123
|
-
captcha.id # Numeric ID of the captcha solved by TwoCaptcha
|
124
|
-
```
|
76
|
+
*Parameters:*
|
125
77
|
|
126
|
-
|
127
|
-
|
78
|
+
- `googlekey`: the Google key for the reCAPTCHA.
|
79
|
+
- `pageurl`: the URL of the page with the reCAPTCHA challenge.
|
128
80
|
|
129
|
-
```ruby
|
130
|
-
"1JJHJ_VuuHAqJKxcaasbTsqw-L1Sm4gD57PTeaEr9-MaETG1vfu2H5zlcwkjsRoZoHxx6V9yUDw8Ig-hYD8kakmSnnjNQd50w_Y_tI3aDLp-s_7ZmhH6pcaoWWsid5hdtMXyvrP9DscDuCLBf7etLle8caPWSaYCpAq9DOTtj5NpSg6-OeCJdGdkjsakFUMeGeqmje87wSajcjmdjl_w4XZBY2zy8fUH6XoAGZ6AeCTulIljBQDObQynKDd-rutPvKNxZasDk-LbhTfw508g1lu9io6jnvm3kbAdnkfZ0x0PkGiUMHU7hnuoW6bXo2Yn_Zt5tDWL7N7wFtY6B0k7cTy73f8er508zReOuoyz2NqL8smDCmcJu05ajkPGt20qzpURMwHaw"
|
131
|
-
```
|
132
81
|
|
133
|
-
|
82
|
+
#### reCAPTCHA v3
|
134
83
|
|
135
|
-
|
84
|
+
```ruby
|
85
|
+
captcha = client.decode_recaptcha_v3!(
|
86
|
+
googlekey: 'xyz',
|
87
|
+
pageurl: 'http://example.com/example=1',
|
88
|
+
action: 'verify',
|
89
|
+
min_score: 0.3, # OPTIONAL
|
90
|
+
)
|
136
91
|
|
137
|
-
|
138
|
-
more information.
|
92
|
+
# The response will be a text (token), which you can access with the `text` method.
|
139
93
|
|
140
|
-
|
141
|
-
|
142
|
-
|
94
|
+
captcha.text
|
95
|
+
"03AOPBWq_RPO2vLzyk0h8gH0cA2X4v3tpYCPZR6Y4yxKy1s3Eo7CHZRQntxrd..."
|
96
|
+
```
|
143
97
|
|
144
|
-
|
98
|
+
*Parameters:*
|
145
99
|
|
146
|
-
|
100
|
+
- `googlekey`: the Google key for the reCAPTCHA.
|
101
|
+
- `pageurl`: the URL of the page with the reCAPTCHA challenge.
|
102
|
+
- `action`: the action name used by the CAPTCHA.
|
103
|
+
- `min_score`: optional parameter. The minimal score needed for the CAPTCHA resolution. Defaults to `0.3`.
|
147
104
|
|
148
|
-
|
105
|
+
> About the `action` parameter: in order to find out what this is, you need to inspect the JavaScript
|
106
|
+
> code of the website looking for a call to the `grecaptcha.execute` function.
|
107
|
+
>
|
108
|
+
> ```javascript
|
109
|
+
> // Example
|
110
|
+
> grecaptcha.execute('6Lc2fhwTAAAAAGatXTzFYfvlQMI2T7B6ji8UVV_f', { action: "examples/v3scores" })
|
111
|
+
> ````
|
149
112
|
|
150
|
-
|
151
|
-
|
113
|
+
> About the `min_score` parameter: it's strongly recommended to use a minimum score of `0.3` as higher
|
114
|
+
> scores are rare.
|
152
115
|
|
153
|
-
|
154
|
-
# captcha.text
|
155
|
-
"coordinates:x=50.66999816894531,y=130.3300018310547;x=236.66998291015625,y=328.3299865722656"
|
156
|
-
```
|
116
|
+
#### hCaptcha
|
157
117
|
|
158
|
-
|
118
|
+
```ruby
|
119
|
+
captcha = client.decode_hcaptcha!(
|
120
|
+
sitekey: 'xyz',
|
121
|
+
pageurl: 'http://example.com/example=1',
|
122
|
+
)
|
159
123
|
|
160
|
-
|
161
|
-
|
162
|
-
|
124
|
+
captcha.text
|
125
|
+
"P0_eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXNza2V5IjoiNnpWV..."
|
126
|
+
```
|
163
127
|
|
164
|
-
|
128
|
+
#### Amazon WAF
|
165
129
|
|
166
130
|
```ruby
|
167
|
-
|
168
|
-
'
|
131
|
+
captcha = client.decode_amazon_waf!(
|
132
|
+
sitekey: 'xyz',
|
133
|
+
pageurl: 'http://example.com/example=1',
|
134
|
+
iv: 'A1A1A1A1A1A1A1A1',
|
135
|
+
context: 'ABcd...',
|
136
|
+
challenge_script: 'http://example.com/challenge.js',
|
137
|
+
)
|
138
|
+
|
139
|
+
puts captcha.text
|
140
|
+
{"captcha_voucher":"eyJ0...","existing_token":"f2ae6..."}
|
169
141
|
```
|
170
142
|
|
171
|
-
|
143
|
+
*Parameters:*
|
172
144
|
|
173
|
-
|
174
|
-
|
175
|
-
(0.3, 0.5 or 0.7) you desire.
|
145
|
+
- `website_key`: the site key for the hCatpcha.
|
146
|
+
- `website_url`: the URL of the page with the hCaptcha challenge.
|
176
147
|
|
177
|
-
|
148
|
+
### 3. Using proxy or other custom options
|
178
149
|
|
179
|
-
|
180
|
-
|
150
|
+
You are allowed to use custom options like `proxy`, `proxytype` or `userAgent` whenever the
|
151
|
+
2Captcha API supports it. Example:
|
181
152
|
|
182
153
|
```ruby
|
183
154
|
options = {
|
184
|
-
|
155
|
+
sitekey: 'xyz',
|
185
156
|
pageurl: 'http://example.com/example=1',
|
186
|
-
|
187
|
-
|
157
|
+
proxy: 'login:password@123.123.123.123:3128',
|
158
|
+
userAgent: 'user agent',
|
188
159
|
}
|
189
160
|
|
190
|
-
captcha = client.
|
191
|
-
captcha.text # Solution of the captcha
|
192
|
-
captcha.id # Numeric ID of the captcha solved by TwoCaptcha
|
193
|
-
```
|
194
|
-
|
195
|
-
The solution (`captcha.text`) will be a code that validates the form, like the
|
196
|
-
following:
|
197
|
-
|
198
|
-
```ruby
|
199
|
-
"1JJHJ_VuuHAqJKxcaasbTsqw-L1Sm4gD57PTeaEr9-MaETG1vfu2H5zlcwkjsRoZoHxx6V9yUDw8Ig-hYD8kakmSnnjNQd50w_Y_tI3aDLp-s_7ZmhH6pcaoWWsid5hdtMXyvrP9DscDuCLBf7etLle8caPWSaYCpAq9DOTtj5NpSg6-OeCJdGdkjsakFUMeGeqmje87wSajcjmdjl_w4XZBY2zy8fUH6XoAGZ6AeCTulIljBQDObQynKDd-rutPvKNxZasDk-LbhTfw508g1lu9io6jnvm3kbAdnkfZ0x0PkGiUMHU7hnuoW6bXo2Yn_Zt5tDWL7N7wFtY6B0k7cTy73f8er508zReOuoyz2NqL8smDCmcJu05ajkPGt20qzpURMwHaw"
|
161
|
+
captcha = client.decode_hcaptcha!(options)
|
200
162
|
```
|
201
163
|
|
202
|
-
|
203
|
-
|
204
|
-
This method allows you to solve hCaptcha.
|
205
|
-
|
206
|
-
There are two methods available:
|
164
|
+
### 4. Retrieve a previously solved CAPTCHA
|
207
165
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
**Send the `sitekey` and `pageurl` parameters**
|
166
|
+
```ruby
|
167
|
+
captcha = client.captcha('130920620') # with 130920620 being the CAPTCHA id
|
168
|
+
```
|
212
169
|
|
213
|
-
|
214
|
-
identify the website in which the CAPTCHA is found.
|
170
|
+
### 5. Report an incorrectly solved CAPTCHA for a refund
|
215
171
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
pageurl: 'http://example.com/example=1'
|
220
|
-
}
|
172
|
+
```ruby
|
173
|
+
client.report!('130920620', 'reportbad') # with 130920620 being the CAPTCHA id
|
174
|
+
# returns `true` if successfully reported
|
221
175
|
|
222
|
-
|
223
|
-
|
224
|
-
|
176
|
+
client.report!('256892751', 'reportgood') # with 256892751 being the CAPTCHA id
|
177
|
+
# returns `true` if successfully reported
|
178
|
+
```
|
225
179
|
|
226
|
-
|
180
|
+
### 6. Get your account balance
|
227
181
|
|
228
|
-
|
182
|
+
```ruby
|
183
|
+
client.balance
|
184
|
+
# returns a Float balance in USD.
|
185
|
+
```
|
229
186
|
|
230
|
-
|
231
|
-
options = {
|
232
|
-
sitekey: 'xyz',
|
233
|
-
pageurl: 'http://example.com/example=1',
|
234
|
-
proxy: 'login:password@123.123.123.123:3128',
|
235
|
-
userAgent: 'user agent'
|
236
|
-
}
|
187
|
+
### 7. Get usage statistics for a specific date
|
237
188
|
|
238
|
-
|
239
|
-
|
189
|
+
```ruby
|
190
|
+
client.stats(Date.new(2022, 10, 7))
|
191
|
+
# returns an XML string with your usage statistics.
|
192
|
+
```
|
240
193
|
|
241
194
|
## Notes
|
242
195
|
|
243
|
-
|
196
|
+
### Thread-safety
|
244
197
|
|
245
198
|
The API is thread-safe, which means it is perfectly fine to share a client
|
246
199
|
instance between multiple threads.
|
247
200
|
|
248
|
-
|
201
|
+
### Ruby dependencies
|
249
202
|
|
250
203
|
TwoCaptcha don't require specific dependencies. That saves you memory and
|
251
204
|
avoid conflicts with other gems.
|
252
205
|
|
253
|
-
|
206
|
+
### Input image format
|
254
207
|
|
255
|
-
Any format you use in the
|
256
|
-
always be converted to a raw64
|
257
|
-
you already have this format
|
258
|
-
|
208
|
+
Any format you use in the `decode_image!` method (`url`, `file`, `path`, `raw` or `raw64`)
|
209
|
+
will always be converted to a `raw64`, which is a base64-encoded binary string.
|
210
|
+
So, if you already have this format on your end, there is no need for convertions
|
211
|
+
before calling the API.
|
259
212
|
|
260
213
|
> Our recomendation is to never convert your image format, unless needed. Let
|
261
214
|
> the gem convert internally. It may save you resources (CPU, memory and IO).
|
262
215
|
|
263
|
-
|
216
|
+
### Versioning
|
264
217
|
|
265
218
|
TwoCaptcha gem uses [Semantic Versioning](http://semver.org/).
|
266
219
|
|
267
|
-
|
268
|
-
|
269
|
-
* MRI 2.2.2
|
270
|
-
* MRI 2.2.0
|
271
|
-
* MRI 2.1.4
|
272
|
-
* MRI 2.0.0
|
273
|
-
|
274
|
-
## Contributing
|
220
|
+
### Contributing
|
275
221
|
|
276
222
|
1. Fork it ( https://github.com/infosimples/two_captcha/fork )
|
277
223
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
@@ -287,4 +233,4 @@ https://github.com/infosimples/two_captcha/graphs/contributors
|
|
287
233
|
|
288
234
|
# License
|
289
235
|
|
290
|
-
MIT License. Copyright (C) 2011-
|
236
|
+
MIT License. Copyright (C) 2011-2022 Infosimples. https://infosimples.com/
|
data/lib/two_captcha/client.rb
CHANGED
@@ -30,11 +30,12 @@ module TwoCaptcha
|
|
30
30
|
# @return [TwoCaptcha::Captcha] The captcha (with solution) or an empty
|
31
31
|
# captcha instance if something goes wrong.
|
32
32
|
#
|
33
|
-
def
|
34
|
-
|
33
|
+
def decode_image(options = {})
|
34
|
+
decode_image!(options)
|
35
35
|
rescue TwoCaptcha::Error => ex
|
36
36
|
TwoCaptcha::Captcha.new
|
37
37
|
end
|
38
|
+
alias :decode :decode_image
|
38
39
|
|
39
40
|
# Decode the text from an image (i.e. solve a captcha).
|
40
41
|
#
|
@@ -60,7 +61,7 @@ module TwoCaptcha
|
|
60
61
|
# @return [TwoCaptcha::Captcha] The captcha (with solution) if an error is
|
61
62
|
# not raised.
|
62
63
|
#
|
63
|
-
def
|
64
|
+
def decode_image!(options = {})
|
64
65
|
started_at = Time.now
|
65
66
|
|
66
67
|
raw64 = load_captcha(options)
|
@@ -77,6 +78,7 @@ module TwoCaptcha
|
|
77
78
|
|
78
79
|
decoded_captcha
|
79
80
|
end
|
81
|
+
alias :decode! :decode_image!
|
80
82
|
|
81
83
|
#
|
82
84
|
# Solve reCAPTCHA v2.
|
@@ -96,7 +98,7 @@ module TwoCaptcha
|
|
96
98
|
#
|
97
99
|
# @param [Hash] options Options hash.
|
98
100
|
# @option options [String] :googlekey The open key of the site in which recaptcha is installed.
|
99
|
-
# @option options [String] :pageurl The URL of the page where the recaptcha is
|
101
|
+
# @option options [String] :pageurl The URL of the page where the recaptcha is present.
|
100
102
|
#
|
101
103
|
# @return [TwoCaptcha::Captcha] The solution of the given captcha.
|
102
104
|
#
|
@@ -136,7 +138,7 @@ module TwoCaptcha
|
|
136
138
|
#
|
137
139
|
# @param [Hash] options Options hash.
|
138
140
|
# @option options [String] :googlekey The open key of the site in which recaptcha is installed.
|
139
|
-
# @option options [String] :pageurl The URL of the page where the recaptcha is
|
141
|
+
# @option options [String] :pageurl The URL of the page where the recaptcha is present.
|
140
142
|
# @option options [String] :action The action paramenter present on the page that uses recaptcha.
|
141
143
|
# @option options [String] :min_score The minimum score necessary to pass the challenge.
|
142
144
|
#
|
@@ -181,7 +183,7 @@ module TwoCaptcha
|
|
181
183
|
#
|
182
184
|
# @param [Hash] options Options hash.
|
183
185
|
# @option options [String] :sitekey The key of the site in which hCaptcha is installed.
|
184
|
-
# @option options [String] :pageurl The URL of the page where the
|
186
|
+
# @option options [String] :pageurl The URL of the page where the hCaptcha is present.
|
185
187
|
#
|
186
188
|
# @return [TwoCaptcha::Captcha] The solution of the given captcha.
|
187
189
|
#
|
@@ -203,6 +205,49 @@ module TwoCaptcha
|
|
203
205
|
decoded_captcha
|
204
206
|
end
|
205
207
|
|
208
|
+
# Solve Amazon WAF.
|
209
|
+
#
|
210
|
+
# @param [Hash] options Options hash. Check docs for the method decode_amazon_waf!.
|
211
|
+
#
|
212
|
+
# @return [TwoCaptcha::Captcha] The solution of the given captcha.
|
213
|
+
#
|
214
|
+
def decode_amazon_waf(options = {})
|
215
|
+
decode_amazon_waf!(opt)
|
216
|
+
rescue TwoCaptcha::Error => ex
|
217
|
+
TwoCaptcha::Captcha.new
|
218
|
+
end
|
219
|
+
|
220
|
+
#
|
221
|
+
# Solve Amazon WAF.
|
222
|
+
#
|
223
|
+
# @param [Hash] options Options hash.
|
224
|
+
# @option options [String] :sitekey The key of the site in which Amazon WAF is installed.
|
225
|
+
# @option options [String] :pageurl The URL of the page where the Amazon WAF is present.
|
226
|
+
# @option options [String] :iv The value of the `iv` parameter found on the page.
|
227
|
+
# @option options [String] :context The value of the `context` parameter found on the page.
|
228
|
+
# @option options [String] :challenge_script The source URL of challenge.js script on the page.
|
229
|
+
# @option options [String] :captcha_script The source URL of captcha.js script on the page
|
230
|
+
#
|
231
|
+
# @return [TwoCaptcha::Captcha] The solution of the given captcha.
|
232
|
+
#
|
233
|
+
def decode_amazon_waf!(options = {})
|
234
|
+
started_at = Time.now
|
235
|
+
|
236
|
+
fail(TwoCaptcha::ArgumentError) if options[:sitekey].empty? || options[:pageurl].empty? || options[:iv].empty? || options[:context].empty?
|
237
|
+
|
238
|
+
upload_options = { method: 'amazon_waf' }.merge(options)
|
239
|
+
decoded_captcha = upload(upload_options)
|
240
|
+
|
241
|
+
# pool untill the answer is ready
|
242
|
+
while decoded_captcha.text.to_s.empty?
|
243
|
+
sleep([polling, 10].max) # sleep at least 10 seconds
|
244
|
+
decoded_captcha = captcha(decoded_captcha.id)
|
245
|
+
fail TwoCaptcha::Timeout if (Time.now - started_at) > timeout
|
246
|
+
end
|
247
|
+
|
248
|
+
decoded_captcha
|
249
|
+
end
|
250
|
+
|
206
251
|
# Upload a captcha to 2Captcha.
|
207
252
|
#
|
208
253
|
# This method will not return the solution. It helps on separating concerns.
|
data/lib/two_captcha/version.rb
CHANGED
data/two_captcha.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler", "
|
26
|
-
spec.add_development_dependency "rake", "
|
25
|
+
spec.add_development_dependency "bundler", ">= 2.2.33"
|
26
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
27
27
|
spec.add_development_dependency "rspec", "~> 3.1"
|
28
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: two_captcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Barbolo
|
@@ -9,36 +9,36 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 2.2.33
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 2.2.33
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 12.3.3
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 12.3.3
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
106
|
+
rubygems_version: 3.3.26
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Ruby API for 2Captcha (Captcha Solver as a Service)
|