two_captcha 1.5.0 → 1.6.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 +24 -0
- data/lib/two_captcha/client.rb +44 -0
- data/lib/two_captcha/errors.rb +6 -0
- data/lib/two_captcha/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85dec926f62d43f6629fea1232276b55950cac27c107e64d064f6374f571c6b6
|
4
|
+
data.tar.gz: 9e962be8d8d1dd76f6cfe7644003a042b3bcccf216aa5d820fd057c95d930c22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11dc25d38866f051f13963f460c9b8d5b813d0960b4f1ce8fa3b0c589555d368021cae3994cd1e9d0e6f730940a6921fa91173a70e48a29ec25b7a3903ac814e
|
7
|
+
data.tar.gz: 762fd992e1b9fa35cfc91baf729d280d123298a46f92b75a6dc03e3b42294184d3a4c84cfc449b5d6d44615f54434c5a1d9c0b565ce1ab7d310cf907996b0d50
|
data/README.md
CHANGED
@@ -199,6 +199,30 @@ following:
|
|
199
199
|
"1JJHJ_VuuHAqJKxcaasbTsqw-L1Sm4gD57PTeaEr9-MaETG1vfu2H5zlcwkjsRoZoHxx6V9yUDw8Ig-hYD8kakmSnnjNQd50w_Y_tI3aDLp-s_7ZmhH6pcaoWWsid5hdtMXyvrP9DscDuCLBf7etLle8caPWSaYCpAq9DOTtj5NpSg6-OeCJdGdkjsakFUMeGeqmje87wSajcjmdjl_w4XZBY2zy8fUH6XoAGZ6AeCTulIljBQDObQynKDd-rutPvKNxZasDk-LbhTfw508g1lu9io6jnvm3kbAdnkfZ0x0PkGiUMHU7hnuoW6bXo2Yn_Zt5tDWL7N7wFtY6B0k7cTy73f8er508zReOuoyz2NqL8smDCmcJu05ajkPGt20qzpURMwHaw"
|
200
200
|
```
|
201
201
|
|
202
|
+
## hCaptcha
|
203
|
+
|
204
|
+
This method allows you to solve hCaptcha.
|
205
|
+
|
206
|
+
There are two methods available:
|
207
|
+
|
208
|
+
- `decode_hcaptcha`: solves hCaptcha CAPTCHAs. It doesn't raise exceptions.
|
209
|
+
- `decode_hcaptcha!`: solves hCaptcha CAPTCHAs. It may raise an error if something goes wrong.
|
210
|
+
|
211
|
+
**Send the `sitekey` and `pageurl` parameters**
|
212
|
+
|
213
|
+
This method requires no browser emulation. You can send two parameters that
|
214
|
+
identify the website in which the CAPTCHA is found.
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
options = {
|
218
|
+
sitekey: 'xyz',
|
219
|
+
pageurl: 'http://example.com/example=1'
|
220
|
+
}
|
221
|
+
|
222
|
+
captcha = client.decode_hcaptcha!(options)
|
223
|
+
captcha.text # Solution of the captcha
|
224
|
+
```
|
225
|
+
|
202
226
|
## Notes
|
203
227
|
|
204
228
|
#### Thread-safety
|
data/lib/two_captcha/client.rb
CHANGED
@@ -171,6 +171,50 @@ module TwoCaptcha
|
|
171
171
|
decoded_captcha
|
172
172
|
end
|
173
173
|
|
174
|
+
#
|
175
|
+
# Solve hCaptcha.
|
176
|
+
#
|
177
|
+
# @param [Hash] options Options hash. Check docs for the method decode_hcaptcha!.
|
178
|
+
#
|
179
|
+
# @return [TwoCaptcha::Captcha] The solution of the given captcha.
|
180
|
+
#
|
181
|
+
def decode_hcaptcha(options = {})
|
182
|
+
decode_hcaptcha!(options)
|
183
|
+
rescue TwoCaptcha::Error => ex
|
184
|
+
TwoCaptcha::Captcha.new
|
185
|
+
end
|
186
|
+
|
187
|
+
#
|
188
|
+
# Solve hCaptcha.
|
189
|
+
#
|
190
|
+
# @param [Hash] options Options hash.
|
191
|
+
# @option options [String] :sitekey The key of the site in which hCaptcha is installed.
|
192
|
+
# @option options [String] :pageurl The URL of the page where the recaptcha is encountered.
|
193
|
+
#
|
194
|
+
# @return [TwoCaptcha::Captcha] The solution of the given captcha.
|
195
|
+
#
|
196
|
+
def decode_hcaptcha!(options = {})
|
197
|
+
started_at = Time.now
|
198
|
+
|
199
|
+
fail(TwoCaptcha::GoogleKey) if options[:sitekey].empty?
|
200
|
+
|
201
|
+
upload_options = {
|
202
|
+
method: 'hcaptcha',
|
203
|
+
sitekey: options[:sitekey],
|
204
|
+
pageurl: options[:pageurl]
|
205
|
+
}
|
206
|
+
decoded_captcha = upload(upload_options)
|
207
|
+
|
208
|
+
# pool untill the answer is ready
|
209
|
+
while decoded_captcha.text.to_s.empty?
|
210
|
+
sleep([polling, 10].max) # sleep at least 10 seconds
|
211
|
+
decoded_captcha = captcha(decoded_captcha.id)
|
212
|
+
fail TwoCaptcha::Timeout if (Time.now - started_at) > timeout
|
213
|
+
end
|
214
|
+
|
215
|
+
decoded_captcha
|
216
|
+
end
|
217
|
+
|
174
218
|
# Upload a captcha to 2Captcha.
|
175
219
|
#
|
176
220
|
# This method will not return the solution. It helps on separating concerns.
|
data/lib/two_captcha/errors.rb
CHANGED
@@ -26,6 +26,12 @@ module TwoCaptcha
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
class SiteKey < Error
|
30
|
+
def initialize
|
31
|
+
super('Missing sitekey parameter')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
29
35
|
class WrongUserKey < Error
|
30
36
|
def initialize
|
31
37
|
super('Wrong “key” parameter format, it should contain 32 symbols')
|
data/lib/two_captcha/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: two_captcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Barbolo
|
8
8
|
- Rafael Ivan Garcia
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -88,7 +88,7 @@ homepage: https://github.com/infosimples/two_captcha
|
|
88
88
|
licenses:
|
89
89
|
- MIT
|
90
90
|
metadata: {}
|
91
|
-
post_install_message:
|
91
|
+
post_install_message:
|
92
92
|
rdoc_options: []
|
93
93
|
require_paths:
|
94
94
|
- lib
|
@@ -103,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.0.
|
107
|
-
signing_key:
|
106
|
+
rubygems_version: 3.0.6
|
107
|
+
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Ruby API for 2Captcha (Captcha Solver as a Service)
|
110
110
|
test_files:
|