recognize 1.0.0 → 2.0.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.
- package/README.md +0 -168
- package/example/test.js +22 -20
- package/index.js +78 -228
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# Recognize
|
|
2
|
-
|
|
3
|
-
[](https://nodei.co/npm/recognize/)
|
|
4
|
-
## Installation
|
|
5
|
-
Using NPM utility to install module directly:
|
|
6
|
-
```npm
|
|
7
|
-
npm install recognize
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
## Service
|
|
11
|
-
* [rucaptcha](https://rucaptcha.com/?from=1027759)
|
|
12
|
-
* [antigate](https://anti-captcha.com)
|
|
13
|
-
* [captcha24](http://captcha24.com)
|
|
14
|
-
|
|
15
|
-
## Documentation
|
|
16
|
-
* [solving](#solving)
|
|
17
|
-
* [balance](#balance)
|
|
18
|
-
* [report](#report)
|
|
19
|
-
|
|
20
|
-
<a name="solving" />
|
|
21
|
-
### [Recognize Object].solving()
|
|
22
|
-
|
|
23
|
-
__Arguments:__
|
|
24
|
-
|
|
25
|
-
1. File buffer
|
|
26
|
-
2. [Optional parameters](#optional)
|
|
27
|
-
3. Callback function
|
|
28
|
-
|
|
29
|
-
```js
|
|
30
|
-
recognize.solving(data, {numeric:1, min_len:5}, function(err, id, code)
|
|
31
|
-
{
|
|
32
|
-
if(err) throw err;
|
|
33
|
-
console.log(id, code);
|
|
34
|
-
});
|
|
35
|
-
```
|
|
36
|
-
OR
|
|
37
|
-
```js
|
|
38
|
-
recognize.solving(data, function(err, id, code)
|
|
39
|
-
{
|
|
40
|
-
if(err) throw err;
|
|
41
|
-
console.log(id, code);
|
|
42
|
-
});
|
|
43
|
-
```
|
|
44
|
-
<a name="balance" />
|
|
45
|
-
### [Recognize Object].balance()
|
|
46
|
-
```js
|
|
47
|
-
recognize.balance(function(err, price)
|
|
48
|
-
{
|
|
49
|
-
if(err) throw err;
|
|
50
|
-
console.log(price);
|
|
51
|
-
});
|
|
52
|
-
```
|
|
53
|
-
<a name="report" />
|
|
54
|
-
### [Recognize Object].report()
|
|
55
|
-
```js
|
|
56
|
-
recognize.report(id, function(err, answer)
|
|
57
|
-
{
|
|
58
|
-
console.log(answer); //OK_REPORT_RECORDED or ERROR_WRONG_CAPTCHA_ID
|
|
59
|
-
});
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Example
|
|
63
|
-
```js
|
|
64
|
-
var recognize = new Recognize('antigate', {
|
|
65
|
-
key:'api-key'
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
recognize.balanse(function(price)
|
|
69
|
-
{
|
|
70
|
-
console.log('My balance:', price);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
fs.readFile('./captcha.png', function(err, data){
|
|
74
|
-
recognize.solving(data, function(err, id, code)
|
|
75
|
-
{
|
|
76
|
-
if(err) throw err;
|
|
77
|
-
if(isValide(code))
|
|
78
|
-
console.log('Captcha:', code);
|
|
79
|
-
else
|
|
80
|
-
{
|
|
81
|
-
console.log('Captcha not valid');
|
|
82
|
-
recognize.report(id, function(err, answer)
|
|
83
|
-
{
|
|
84
|
-
console.log(answer);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
<a name="optional" />
|
|
92
|
-
## Optional parameters
|
|
93
|
-
<table class="table" width="100%">
|
|
94
|
-
<thead>
|
|
95
|
-
<tr>
|
|
96
|
-
<td>Parameter</td>
|
|
97
|
-
<td>Type</td>
|
|
98
|
-
<td>Possible values</td>
|
|
99
|
-
<td>Description</td>
|
|
100
|
-
</tr>
|
|
101
|
-
</thead>
|
|
102
|
-
<tbody>
|
|
103
|
-
<tr>
|
|
104
|
-
<td>phrase</td>
|
|
105
|
-
<td>integer</td>
|
|
106
|
-
<td>0, 1</td>
|
|
107
|
-
<td>
|
|
108
|
-
<div><b>0</b> = default value</div>
|
|
109
|
-
<div><b>1</b> = captcha has 2-3 words</div>
|
|
110
|
-
</td>
|
|
111
|
-
</tr>
|
|
112
|
-
<tr>
|
|
113
|
-
<td>regsense</td>
|
|
114
|
-
<td>integer</td>
|
|
115
|
-
<td>0, 1</td>
|
|
116
|
-
<td>
|
|
117
|
-
<div><b>0</b> = default value</div>
|
|
118
|
-
<div><b>1</b> = captcha is case sensitive</div>
|
|
119
|
-
</td>
|
|
120
|
-
</tr>
|
|
121
|
-
<tr>
|
|
122
|
-
<td>numeric</td>
|
|
123
|
-
<td>integer</td>
|
|
124
|
-
<td>0, 1, 2</td>
|
|
125
|
-
<td>
|
|
126
|
-
<div><b>0</b> = default value</div>
|
|
127
|
-
<div><b>1</b> = captcha consists of digits only</div>
|
|
128
|
-
<div><b>2</b> = captcha does not contain any digits</div>
|
|
129
|
-
</td>
|
|
130
|
-
</tr>
|
|
131
|
-
<tr>
|
|
132
|
-
<td>calc</td>
|
|
133
|
-
<td>integer</td>
|
|
134
|
-
<td>0, 1</td>
|
|
135
|
-
<td>
|
|
136
|
-
<div><b>0</b> = default value</div>
|
|
137
|
-
<div><b>1</b> = arithmetical operation must be performed</div>
|
|
138
|
-
</td>
|
|
139
|
-
</tr>
|
|
140
|
-
<tr>
|
|
141
|
-
<td>min_len</td>
|
|
142
|
-
<td>integer</td>
|
|
143
|
-
<td>0..20</td>
|
|
144
|
-
<td>
|
|
145
|
-
<div><b>0</b> = default value</div>
|
|
146
|
-
<div><b>1..20</b> = minimum length of captcha text required to input</div>
|
|
147
|
-
</td>
|
|
148
|
-
</tr>
|
|
149
|
-
<tr>
|
|
150
|
-
<td>max_len</td>
|
|
151
|
-
<td>integer</td>
|
|
152
|
-
<td>0..20</td>
|
|
153
|
-
<td>
|
|
154
|
-
<div><b>0</b> = default value</div>
|
|
155
|
-
<div><b>1..20</b> = maximum length of captcha text required to input</div>
|
|
156
|
-
</td>
|
|
157
|
-
</tr>
|
|
158
|
-
<tr>
|
|
159
|
-
<td>is_russian</td>
|
|
160
|
-
<td>integer</td>
|
|
161
|
-
<td>0, 1</td>
|
|
162
|
-
<td>
|
|
163
|
-
<div><b>0</b> = default value</div>
|
|
164
|
-
<div><b>1</b> = captcha goes to Russian Queue</div>
|
|
165
|
-
</td>
|
|
166
|
-
</tr>
|
|
167
|
-
</tbody><tbody>
|
|
168
|
-
</tbody></table>
|
package/example/test.js
CHANGED
|
@@ -10,26 +10,28 @@ console.log("My balance:", price);
|
|
|
10
10
|
|
|
11
11
|
// const buff = await readFile("./example/captcha.png");
|
|
12
12
|
|
|
13
|
-
const { id, result } = await recognize
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
// const { id, result } = await recognize
|
|
14
|
+
// .solvingRecaptcha3(
|
|
15
|
+
// "https://www.reestr-zalogov.ru/search/index",
|
|
16
|
+
// "6LdKJhMaAAAAAIfeHC6FZc-UVfzDQpiOjaJUWoxr",
|
|
17
|
+
// "search_notary",
|
|
18
|
+
// "0.3"
|
|
19
|
+
// )
|
|
20
|
+
// .catch(console.error);
|
|
21
21
|
|
|
22
|
-
console.log(result);
|
|
22
|
+
// console.log(id, result);
|
|
23
23
|
|
|
24
|
-
//
|
|
24
|
+
// console.log(await recognize.solvingImage(buff));
|
|
25
|
+
|
|
26
|
+
// const r = await recognize.reportGood(1).catch((err) => err.message);
|
|
25
27
|
// console.log(r);
|
|
26
|
-
// recognize.solving(
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
28
|
+
// recognize.solving(buff, function (err, id, code) {
|
|
29
|
+
// if (err) throw err;
|
|
30
|
+
// if (code) console.log("Captcha:", code);
|
|
31
|
+
// else {
|
|
32
|
+
// console.log("Captcha not valid");
|
|
33
|
+
// recognize.report(id, function (err, answer) {
|
|
34
|
+
// console.log(answer);
|
|
35
|
+
// });
|
|
36
|
+
// }
|
|
37
|
+
// });
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setTimeout } from "node:timers/promises";
|
|
2
|
-
import
|
|
2
|
+
import got from "got";
|
|
3
3
|
|
|
4
4
|
export const SOURCE = {
|
|
5
5
|
RUCAPTCHA: "RUCAPTCHA",
|
|
@@ -9,15 +9,15 @@ export const SOURCE = {
|
|
|
9
9
|
|
|
10
10
|
const _SOURCE = {
|
|
11
11
|
[SOURCE.RUCAPTCHA]: {
|
|
12
|
-
baseUrl: "rucaptcha.com",
|
|
12
|
+
baseUrl: "http://rucaptcha.com",
|
|
13
13
|
soft_id: 768,
|
|
14
14
|
},
|
|
15
15
|
[SOURCE.ANTIGATE]: {
|
|
16
|
-
baseUrl: "anti-captcha.com",
|
|
16
|
+
baseUrl: "http://anti-captcha.com",
|
|
17
17
|
soft_id: 720,
|
|
18
18
|
},
|
|
19
19
|
[SOURCE.CAPTCHA24]: {
|
|
20
|
-
baseUrl: "captcha24.com",
|
|
20
|
+
baseUrl: "http://captcha24.com",
|
|
21
21
|
soft_id: 921,
|
|
22
22
|
},
|
|
23
23
|
};
|
|
@@ -27,145 +27,79 @@ export default class Recognize {
|
|
|
27
27
|
if (!options || !options.key) throw new Error("not key");
|
|
28
28
|
const source = _SOURCE[sourceCode];
|
|
29
29
|
if (!source) throw new Error("invalid type");
|
|
30
|
-
|
|
30
|
+
this.rp = got.extend({
|
|
31
|
+
prefixUrl: source.baseUrl,
|
|
32
|
+
resolveBodyOnly: true,
|
|
33
|
+
responseType: "json",
|
|
34
|
+
});
|
|
31
35
|
this._options = {
|
|
32
36
|
...options,
|
|
33
|
-
baseUrl: source.baseUrl,
|
|
34
37
|
soft_id: source.soft_id,
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
const { status, request } = JSON.parse(body.join(""));
|
|
55
|
-
if (status === 1) {
|
|
56
|
-
return resolve(request);
|
|
57
|
-
}
|
|
58
|
-
return reject(new Error(request));
|
|
59
|
-
} catch (err) {
|
|
60
|
-
reject(err);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
)
|
|
65
|
-
.on("error", reject);
|
|
41
|
+
async _waitResult(id) {
|
|
42
|
+
await setTimeout(1000);
|
|
43
|
+
const { status, request } = await this.rp.get("res.php", {
|
|
44
|
+
searchParams: { key: this._options.key, action: "get", id, json: 1 },
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (request === "CAPCHA_NOT_READY") return this._waitResult(id);
|
|
48
|
+
else if (status === 0) return Promise.reject(request);
|
|
49
|
+
|
|
50
|
+
return request;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async balanse() {
|
|
54
|
+
const { request } = await this.rp.get("res.php", {
|
|
55
|
+
searchParams: { key: this._options.key, action: "getbalance", json: 1 },
|
|
66
56
|
});
|
|
57
|
+
|
|
58
|
+
return request;
|
|
67
59
|
}
|
|
68
60
|
|
|
69
|
-
solvingImage(buff, options = {}) {
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
async solvingImage(buff, options = {}) {
|
|
62
|
+
const { status, request } = await this.rp.post("in.php", {
|
|
63
|
+
json: {
|
|
72
64
|
...options,
|
|
73
65
|
soft_id: this._options.soft_id,
|
|
74
66
|
method: "base64",
|
|
75
67
|
key: this._options.key,
|
|
76
68
|
body: buff.toString("base64"),
|
|
77
|
-
json:
|
|
78
|
-
}
|
|
69
|
+
json: 1,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
79
72
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
port: 80,
|
|
84
|
-
path: "/in.php",
|
|
85
|
-
method: "POST",
|
|
86
|
-
headers: {
|
|
87
|
-
"Content-Type": "application/json",
|
|
88
|
-
"Content-Length": Buffer.byteLength(postData),
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
(res) => {
|
|
92
|
-
const body = [];
|
|
93
|
-
res.setEncoding("utf8");
|
|
94
|
-
res.on("data", (chunk) => {
|
|
95
|
-
body.push(chunk);
|
|
96
|
-
});
|
|
97
|
-
res.on("end", () => {
|
|
98
|
-
const { status, request } = JSON.parse(body.join(""));
|
|
99
|
-
// console.log(request);
|
|
100
|
-
if (status === 1) {
|
|
101
|
-
waitResult(this._options.baseUrl, this._options.key, request)
|
|
102
|
-
.then((result) => resolve({ id: request, result }))
|
|
103
|
-
.catch((error) => reject(error));
|
|
104
|
-
} else {
|
|
105
|
-
reject(new Error(request));
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
);
|
|
73
|
+
if (status === 1) {
|
|
74
|
+
return { result: await this._waitResult(request), id: request };
|
|
75
|
+
}
|
|
110
76
|
|
|
111
|
-
|
|
112
|
-
req.write(postData);
|
|
113
|
-
req.end();
|
|
114
|
-
});
|
|
77
|
+
return Promise.reject(request);
|
|
115
78
|
}
|
|
116
79
|
|
|
117
|
-
solvingRecaptcha2(url, googleKey, options = {}) {
|
|
118
|
-
|
|
119
|
-
|
|
80
|
+
async solvingRecaptcha2(url, googleKey, options = {}) {
|
|
81
|
+
const { status, request } = await this.rp.post("in.php", {
|
|
82
|
+
json: {
|
|
120
83
|
...options,
|
|
121
84
|
soft_id: this._options.soft_id,
|
|
122
85
|
method: "userrecaptcha",
|
|
123
86
|
key: this._options.key,
|
|
124
87
|
pageurl: url,
|
|
125
88
|
googlekey: googleKey,
|
|
126
|
-
json:
|
|
127
|
-
}
|
|
89
|
+
json: 1,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
128
92
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
port: 80,
|
|
133
|
-
path: "/in.php",
|
|
134
|
-
method: "POST",
|
|
135
|
-
headers: {
|
|
136
|
-
"Content-Type": "application/json",
|
|
137
|
-
"Content-Length": Buffer.byteLength(postData),
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
(res) => {
|
|
141
|
-
const body = [];
|
|
142
|
-
res.setEncoding("utf8");
|
|
143
|
-
res.on("data", (chunk) => {
|
|
144
|
-
body.push(chunk);
|
|
145
|
-
});
|
|
146
|
-
res.on("end", () => {
|
|
147
|
-
const { status, request } = JSON.parse(body.join(""));
|
|
148
|
-
// console.log(request);
|
|
149
|
-
if (status === 1) {
|
|
150
|
-
waitResult(this._options.baseUrl, this._options.key, request)
|
|
151
|
-
.then((result) => resolve({ id: request, result }))
|
|
152
|
-
.catch((error) => reject(error));
|
|
153
|
-
} else {
|
|
154
|
-
reject(new Error(request));
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
);
|
|
93
|
+
if (status === 1) {
|
|
94
|
+
return { result: await this._waitResult(request), id: request };
|
|
95
|
+
}
|
|
159
96
|
|
|
160
|
-
|
|
161
|
-
req.write(postData);
|
|
162
|
-
req.end();
|
|
163
|
-
});
|
|
97
|
+
return Promise.reject(request);
|
|
164
98
|
}
|
|
165
99
|
|
|
166
|
-
solvingRecaptcha3(url, googleKey, action, score = "0.3", options = {}) {
|
|
167
|
-
|
|
168
|
-
|
|
100
|
+
async solvingRecaptcha3(url, googleKey, action, score = "0.3", options = {}) {
|
|
101
|
+
const { status, request } = await this.rp.post("in.php", {
|
|
102
|
+
json: {
|
|
169
103
|
...options,
|
|
170
104
|
soft_id: this._options.soft_id,
|
|
171
105
|
method: "userrecaptcha",
|
|
@@ -175,126 +109,42 @@ export default class Recognize {
|
|
|
175
109
|
key: this._options.key,
|
|
176
110
|
pageurl: url,
|
|
177
111
|
googlekey: googleKey,
|
|
178
|
-
json:
|
|
179
|
-
}
|
|
112
|
+
json: 1,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
180
115
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
port: 80,
|
|
185
|
-
path: "/in.php",
|
|
186
|
-
method: "POST",
|
|
187
|
-
headers: {
|
|
188
|
-
"Content-Type": "application/json",
|
|
189
|
-
"Content-Length": Buffer.byteLength(postData),
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
(res) => {
|
|
193
|
-
const body = [];
|
|
194
|
-
res.setEncoding("utf8");
|
|
195
|
-
res.on("data", (chunk) => {
|
|
196
|
-
body.push(chunk);
|
|
197
|
-
});
|
|
198
|
-
res.on("end", () => {
|
|
199
|
-
const { status, request } = JSON.parse(body.join(""));
|
|
200
|
-
// console.log(request);
|
|
201
|
-
if (status === 1) {
|
|
202
|
-
waitResult(this._options.baseUrl, this._options.key, request)
|
|
203
|
-
.then((result) => resolve({ id: request, result }))
|
|
204
|
-
.catch((error) => reject(error));
|
|
205
|
-
} else {
|
|
206
|
-
reject(new Error(request));
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
);
|
|
116
|
+
if (status === 1) {
|
|
117
|
+
return { result: await this._waitResult(request), id: request };
|
|
118
|
+
}
|
|
211
119
|
|
|
212
|
-
|
|
213
|
-
req.write(postData);
|
|
214
|
-
req.end();
|
|
215
|
-
});
|
|
120
|
+
return Promise.reject(request);
|
|
216
121
|
}
|
|
217
122
|
|
|
218
|
-
reportBad(id) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
},
|
|
227
|
-
function (res) {
|
|
228
|
-
const body = [];
|
|
229
|
-
res.setEncoding("utf8");
|
|
230
|
-
res.on("data", function (chunk) {
|
|
231
|
-
body.push(chunk);
|
|
232
|
-
});
|
|
233
|
-
res.on("end", function () {
|
|
234
|
-
const { status, request } = JSON.parse(body.join(""));
|
|
235
|
-
if (status === 0) return reject(new Error(request));
|
|
236
|
-
resolve(request);
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
)
|
|
240
|
-
.on("error", reject);
|
|
123
|
+
async reportBad(id) {
|
|
124
|
+
const { status, request } = await this.rp.get("res.php", {
|
|
125
|
+
searchParams: {
|
|
126
|
+
key: this._options.key,
|
|
127
|
+
action: "reportbad",
|
|
128
|
+
id,
|
|
129
|
+
json: 1,
|
|
130
|
+
},
|
|
241
131
|
});
|
|
132
|
+
|
|
133
|
+
if (status === 0) return false;
|
|
134
|
+
return true;
|
|
242
135
|
}
|
|
243
136
|
|
|
244
|
-
reportGood(id) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
},
|
|
253
|
-
function (res) {
|
|
254
|
-
const body = [];
|
|
255
|
-
res.setEncoding("utf8");
|
|
256
|
-
res.on("data", function (chunk) {
|
|
257
|
-
body.push(chunk);
|
|
258
|
-
});
|
|
259
|
-
res.on("end", function () {
|
|
260
|
-
const { status, request } = JSON.parse(body.join(""));
|
|
261
|
-
if (status === 0) return reject(new Error(request));
|
|
262
|
-
resolve(request);
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
)
|
|
266
|
-
.on("error", reject);
|
|
137
|
+
async reportGood(id) {
|
|
138
|
+
const { status, request } = await this.rp.get("res.php", {
|
|
139
|
+
searchParams: {
|
|
140
|
+
key: this._options.key,
|
|
141
|
+
action: "reportgood",
|
|
142
|
+
id,
|
|
143
|
+
json: 1,
|
|
144
|
+
},
|
|
267
145
|
});
|
|
146
|
+
|
|
147
|
+
if (status === 0) return false;
|
|
148
|
+
return true;
|
|
268
149
|
}
|
|
269
150
|
}
|
|
270
|
-
|
|
271
|
-
const httpGet = (request) => {
|
|
272
|
-
return new Promise((resolve, reject) => {
|
|
273
|
-
return http
|
|
274
|
-
.get(request, (res) => {
|
|
275
|
-
const body = [];
|
|
276
|
-
res.setEncoding("utf8");
|
|
277
|
-
res.on("data", function (chunk) {
|
|
278
|
-
body.push(chunk);
|
|
279
|
-
});
|
|
280
|
-
res.on("end", () => {
|
|
281
|
-
resolve(JSON.parse(body.join("")));
|
|
282
|
-
});
|
|
283
|
-
})
|
|
284
|
-
.on("error", reject);
|
|
285
|
-
});
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
const waitResult = async (baseUrl, key, id) => {
|
|
289
|
-
await setTimeout(1000);
|
|
290
|
-
const { status, request } = await httpGet({
|
|
291
|
-
hostname: baseUrl,
|
|
292
|
-
port: 80,
|
|
293
|
-
path: `/res.php?key=${key}&action=get&id=${id}&json=1`,
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
if (request === "CAPCHA_NOT_READY") return waitResult(baseUrl, key, id);
|
|
297
|
-
else if (status === 0) throw new Error(request);
|
|
298
|
-
|
|
299
|
-
return request;
|
|
300
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "recognize",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Client for solving services using node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -21,5 +21,8 @@
|
|
|
21
21
|
"bugs": {
|
|
22
22
|
"url": "https://github.com/kdinisv/Recognize/issues"
|
|
23
23
|
},
|
|
24
|
-
"homepage": "https://github.com/kdinisv/Recognize#readme"
|
|
24
|
+
"homepage": "https://github.com/kdinisv/Recognize#readme",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"got": "^12.0.0"
|
|
27
|
+
}
|
|
25
28
|
}
|