two_captcha 1.0.1 → 1.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 +4 -4
- data/README.md +9 -12
- data/lib/two_captcha.rb +1 -0
- data/lib/two_captcha/client.rb +2 -1
- data/lib/two_captcha/models/captcha.rb +4 -0
- data/lib/two_captcha/version.rb +1 -1
- data/spec/lib/client_spec.rb +12 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 055315d1b7cfb0bafcb2542dcdf1996ed273753d
|
4
|
+
data.tar.gz: 62bba1e3f36d178aa38f7a860f50124740d938a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0023a248fbba3ed1af6a714256b3e61ad91616145d2b5db1d5edea2e7da87cebe8c6d88f7e706425c411b3b0e92c4b362207237d04f8312bc79401e3dc6466c6
|
7
|
+
data.tar.gz: 3c161aa8ef5031a56d33873da65c27f474aa6a07999a530e3f39982158841f381baa479e8cf2c32dbe41822f58ecf6ea6ce8312218f11c405eb9ce46d24dbc76
|
data/README.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
Developed by [Infosimples](https://infosimples.com), a
|
2
|
-
offers [data extraction solutions](https://infosimples.com/en/data-engineering)
|
3
|
-
and [Ruby on Rails development](https://infosimples.com/en/software-development).
|
1
|
+
Developed by [Infosimples](https://infosimples.com), a [big data company](https://infosimples.com/en/data-engineering).
|
4
2
|
|
5
3
|
# TwoCaptcha
|
6
4
|
|
@@ -98,17 +96,17 @@ Or install it yourself as:
|
|
98
96
|
# return an XML string with the current service load.
|
99
97
|
```
|
100
98
|
|
101
|
-
##
|
99
|
+
## Clickable CAPTCHAs (e.g. "No CAPTCHA reCAPTCHA")
|
102
100
|
|
103
101
|
To solve captchas similar to
|
104
102
|
[reCAPTCHA v2](https://support.google.com/recaptcha/?hl=en#6262736), you can add
|
105
|
-
the param
|
103
|
+
the param `coordinatescaptcha: 1` to your request.
|
106
104
|
|
107
|
-
Please read the oficial documentation at https://2captcha.com/
|
105
|
+
Please read the oficial documentation at https://2captcha.com/en-api-recaptcha for
|
108
106
|
more information.
|
109
107
|
|
110
108
|
```ruby
|
111
|
-
client.decode(url: 'http://bit.ly/
|
109
|
+
client.decode(url: 'http://bit.ly/clickcaptcha', coordinatescaptcha: 1)
|
112
110
|
```
|
113
111
|
|
114
112
|
**Captcha (screenshot)**
|
@@ -117,13 +115,12 @@ more information.
|
|
117
115
|
|
118
116
|

|
119
117
|
|
120
|
-
The response will be an array containing
|
121
|
-
|
122
|
-
something like:
|
118
|
+
The response will be an array containing coordinates where the captcha should be
|
119
|
+
clicked. For the captcha above it should look something like:
|
123
120
|
|
124
121
|
```ruby
|
125
|
-
# captcha.
|
126
|
-
[
|
122
|
+
# captcha.coordinates
|
123
|
+
[[234, 330], [48, 137]]
|
127
124
|
```
|
128
125
|
|
129
126
|
## Notes
|
data/lib/two_captcha.rb
CHANGED
data/lib/two_captcha/client.rb
CHANGED
@@ -55,6 +55,7 @@ module TwoCaptcha
|
|
55
55
|
# @option options [Integer] :language (0) https://2captcha.com/setting
|
56
56
|
# @option options [Integer] :header_acao (0) https://2captcha.com/setting
|
57
57
|
# @option options [Integer] :id_constructor (0) 23 if new reCAPTCHA.
|
58
|
+
# @option options [Integer] coordinatescaptcha (0) 1 if clickable captcha.
|
58
59
|
#
|
59
60
|
# @return [TwoCaptcha::Captcha] The captcha (with solution) if an error is
|
60
61
|
# not raised.
|
@@ -88,7 +89,7 @@ module TwoCaptcha
|
|
88
89
|
args[:body] = options[:raw64]
|
89
90
|
args[:method] = 'base64'
|
90
91
|
[:phrase, :regsense, :numeric, :calc, :min_len, :max_len, :language,
|
91
|
-
:header_acao, :id_constructor].each do |key|
|
92
|
+
:header_acao, :id_constructor, :coordinatescaptcha].each do |key|
|
92
93
|
args[key] = options[key] if options[key]
|
93
94
|
end
|
94
95
|
response = request('in', :multipart, args)
|
data/lib/two_captcha/version.rb
CHANGED
data/spec/lib/client_spec.rb
CHANGED
@@ -4,7 +4,7 @@ key = CREDENTIALS['key']
|
|
4
4
|
captcha_id = CREDENTIALS['captcha_id']
|
5
5
|
captcha_solution = CREDENTIALS['solution']
|
6
6
|
image64 = Base64.encode64(File.open('captchas/1.png', 'rb').read)
|
7
|
-
|
7
|
+
clickable64 = Base64.encode64(File.open('captchas/2.jpg', 'rb').read)
|
8
8
|
|
9
9
|
describe TwoCaptcha::Client do
|
10
10
|
describe 'create' do
|
@@ -58,15 +58,23 @@ describe TwoCaptcha::Client do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context '
|
61
|
+
context 'clickable CAPTCHA' do
|
62
62
|
before(:all) { @client = TwoCaptcha.new(key) }
|
63
63
|
|
64
64
|
describe '#decode!' do
|
65
|
-
before(:all)
|
65
|
+
before(:all) do
|
66
|
+
@captcha = @client.decode!(raw64: clickable64, coordinatescaptcha: 1)
|
67
|
+
@xy1, @xy2 = @captcha.coordinates.sort_by { |e| e[0] }
|
68
|
+
end
|
66
69
|
|
67
70
|
it { expect(@captcha).to be_a(TwoCaptcha::Captcha) }
|
68
|
-
it { expect(@captcha.indexes).to eq([1, 9]) }
|
69
71
|
it { expect(@captcha.id).to match(/[0-9]{9}/) }
|
72
|
+
|
73
|
+
it { expect(@captcha.coordinates.size).to eq(2) }
|
74
|
+
it { expect(@xy1[0]).to be_between(9, 99).inclusive }
|
75
|
+
it { expect(@xy1[1]).to be_between(97, 187).inclusive }
|
76
|
+
it { expect(@xy2[0]).to be_between(187, 279).inclusive }
|
77
|
+
it { expect(@xy2[1]).to be_between(276, 366).inclusive }
|
70
78
|
end
|
71
79
|
end
|
72
80
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Mita
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|