recognize 0.2.1 → 1.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 CHANGED
@@ -1,167 +1,168 @@
1
- # Recognize
2
-
3
- [![NPM](https://nodei.co/npm/recognize.png?downloads=true&downloadRank=true&stars=true)](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>
12
- * antigate - <https://anti-captcha.com>
13
-
14
- ## Documentation
15
- * [solving](#solving)
16
- * [balance](#balance)
17
- * [report](#report)
18
-
19
- <a name="solving" />
20
- ### [Recognize Object].solving()
21
-
22
- __Arguments:__
23
-
24
- 1. File buffer
25
- 2. [Optional parameters](#optional)
26
- 3. Callback function
27
-
28
- ```js
29
- recognize.solving(data, {numeric:1, min_len:5}, function(err, id, code)
30
- {
31
- if(err) throw err;
32
- console.log(id, code);
33
- });
34
- ```
35
- OR
36
- ```js
37
- recognize.solving(data, function(err, id, code)
38
- {
39
- if(err) throw err;
40
- console.log(id, code);
41
- });
42
- ```
43
- <a name="balance" />
44
- ### [Recognize Object].balance()
45
- ```js
46
- recognize.balance(function(err, price)
47
- {
48
- if(err) throw err;
49
- console.log(price);
50
- });
51
- ```
52
- <a name="report" />
53
- ### [Recognize Object].report()
54
- ```js
55
- recognize.report(id, function(err, answer)
56
- {
57
- console.log(answer); //OK_REPORT_RECORDED or ERROR_WRONG_CAPTCHA_ID
58
- });
59
- ```
60
-
61
- ## Example
62
- ```js
63
- var recognize = new Recognize('antigate', {
64
- key:'api-key'
65
- });
66
-
67
- recognize.balanse(function(price)
68
- {
69
- console.log('My balance:', price);
70
- });
71
-
72
- fs.readFile('./captcha.png', function(err, data){
73
- recognize.solving(data, function(err, id, code)
74
- {
75
- if(err) throw err;
76
- if(isValide(code))
77
- console.log('Captcha:', code);
78
- else
79
- {
80
- console.log('Captcha not valid');
81
- recognize.report(id, function(err, answer)
82
- {
83
- console.log(answer);
84
- });
85
- }
86
- });
87
- });
88
- ```
89
-
90
- <a name="optional" />
91
- ## Optional parameters
92
- <table class="table" width="100%">
93
- <thead>
94
- <tr>
95
- <td>Parameter</td>
96
- <td>Type</td>
97
- <td>Possible values</td>
98
- <td>Description</td>
99
- </tr>
100
- </thead>
101
- <tbody>
102
- <tr>
103
- <td>phrase</td>
104
- <td>integer</td>
105
- <td>0, 1</td>
106
- <td>
107
- <div><b>0</b> = default value</div>
108
- <div><b>1</b> = captcha has 2-3 words</div>
109
- </td>
110
- </tr>
111
- <tr>
112
- <td>regsense</td>
113
- <td>integer</td>
114
- <td>0, 1</td>
115
- <td>
116
- <div><b>0</b> = default value</div>
117
- <div><b>1</b> = captcha is case sensitive</div>
118
- </td>
119
- </tr>
120
- <tr>
121
- <td>numeric</td>
122
- <td>integer</td>
123
- <td>0, 1, 2</td>
124
- <td>
125
- <div><b>0</b> = default value</div>
126
- <div><b>1</b> = captcha consists of digits only</div>
127
- <div><b>2</b> = captcha does not contain any digits</div>
128
- </td>
129
- </tr>
130
- <tr>
131
- <td>calc</td>
132
- <td>integer</td>
133
- <td>0, 1</td>
134
- <td>
135
- <div><b>0</b> = default value</div>
136
- <div><b>1</b> = arithmetical operation must be performed</div>
137
- </td>
138
- </tr>
139
- <tr>
140
- <td>min_len</td>
141
- <td>integer</td>
142
- <td>0..20</td>
143
- <td>
144
- <div><b>0</b> = default value</div>
145
- <div><b>1..20</b> = minimum length of captcha text required to input</div>
146
- </td>
147
- </tr>
148
- <tr>
149
- <td>max_len</td>
150
- <td>integer</td>
151
- <td>0..20</td>
152
- <td>
153
- <div><b>0</b> = default value</div>
154
- <div><b>1..20</b> = maximum length of captcha text required to input</div>
155
- </td>
156
- </tr>
157
- <tr>
158
- <td>is_russian</td>
159
- <td>integer</td>
160
- <td>0, 1</td>
161
- <td>
162
- <div><b>0</b> = default value</div>
163
- <div><b>1</b> = captcha goes to Russian Queue</div>
164
- </td>
165
- </tr>
166
- </tbody><tbody>
167
- </tbody></table>
1
+ # Recognize
2
+
3
+ [![NPM](https://nodei.co/npm/recognize.png?downloads=true&downloadRank=true&stars=true)](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
@@ -1,28 +1,35 @@
1
- var Recognize = require('../recognize');
2
- var fs = require('fs');
1
+ import { readFile } from "node:fs/promises";
2
+ import Recognize, { SOURCE } from "../index.js";
3
3
 
4
- var recognize = new Recognize('rucaptcha', {
5
- key:'api-key'
4
+ const recognize = new Recognize(SOURCE.RUCAPTCHA, {
5
+ key: "api-key",
6
6
  });
7
7
 
8
- recognize.balanse(function(price)
9
- {
10
- console.log('My balance:', price);
11
- });
8
+ const price = await recognize.balanse();
9
+ console.log("My balance:", price);
12
10
 
13
- fs.readFile('./example/captcha.png', function(err, data){
14
- recognize.solving(data, function(err, id, code)
15
- {
16
- if(err) throw err;
17
- if(code)
18
- console.log('Captcha:', code);
19
- else
20
- {
21
- console.log('Captcha not valid');
22
- recognize.report(id, function(err, answer)
23
- {
24
- console.log(answer);
25
- });
26
- }
27
- });
28
- });
11
+ // const buff = await readFile("./example/captcha.png");
12
+
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
+
22
+ console.log(result);
23
+
24
+ // const r = await recognize.reportGood(id).catch((err) => err.message);
25
+ // console.log(r);
26
+ // recognize.solving(data, function (err, id, code) {
27
+ // if (err) throw err;
28
+ // if (code) console.log("Captcha:", code);
29
+ // else {
30
+ // console.log("Captcha not valid");
31
+ // recognize.report(id, function (err, answer) {
32
+ // console.log(answer);
33
+ // });
34
+ // }
35
+ // });
package/index.js ADDED
@@ -0,0 +1,300 @@
1
+ import { setTimeout } from "node:timers/promises";
2
+ import http from "node:http";
3
+
4
+ export const SOURCE = {
5
+ RUCAPTCHA: "RUCAPTCHA",
6
+ ANTIGATE: "ANTIGATE",
7
+ CAPTCHA24: "CAPTCHA24",
8
+ };
9
+
10
+ const _SOURCE = {
11
+ [SOURCE.RUCAPTCHA]: {
12
+ baseUrl: "rucaptcha.com",
13
+ soft_id: 768,
14
+ },
15
+ [SOURCE.ANTIGATE]: {
16
+ baseUrl: "anti-captcha.com",
17
+ soft_id: 720,
18
+ },
19
+ [SOURCE.CAPTCHA24]: {
20
+ baseUrl: "captcha24.com",
21
+ soft_id: 921,
22
+ },
23
+ };
24
+
25
+ export default class Recognize {
26
+ constructor(sourceCode, options) {
27
+ if (!options || !options.key) throw new Error("not key");
28
+ const source = _SOURCE[sourceCode];
29
+ if (!source) throw new Error("invalid type");
30
+
31
+ this._options = {
32
+ ...options,
33
+ baseUrl: source.baseUrl,
34
+ soft_id: source.soft_id,
35
+ };
36
+ }
37
+
38
+ balanse() {
39
+ return new Promise((resolve, reject) => {
40
+ http
41
+ .get(
42
+ {
43
+ hostname: this._options.baseUrl,
44
+ port: 80,
45
+ path: `/res.php?key=${this._options.key}&action=getbalance&json=1`,
46
+ },
47
+ function (res) {
48
+ var body = [];
49
+ res.on("data", function (chunk) {
50
+ body.push(chunk);
51
+ });
52
+ res.on("end", function () {
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);
66
+ });
67
+ }
68
+
69
+ solvingImage(buff, options = {}) {
70
+ return new Promise((resolve, reject) => {
71
+ const postData = JSON.stringify({
72
+ ...options,
73
+ soft_id: this._options.soft_id,
74
+ method: "base64",
75
+ key: this._options.key,
76
+ body: buff.toString("base64"),
77
+ json: "1",
78
+ });
79
+
80
+ const req = http.request(
81
+ {
82
+ hostname: this._options.baseUrl,
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
+ );
110
+
111
+ req.on("error", reject);
112
+ req.write(postData);
113
+ req.end();
114
+ });
115
+ }
116
+
117
+ solvingRecaptcha2(url, googleKey, options = {}) {
118
+ return new Promise((resolve, reject) => {
119
+ const postData = JSON.stringify({
120
+ ...options,
121
+ soft_id: this._options.soft_id,
122
+ method: "userrecaptcha",
123
+ key: this._options.key,
124
+ pageurl: url,
125
+ googlekey: googleKey,
126
+ json: "1",
127
+ });
128
+
129
+ const req = http.request(
130
+ {
131
+ hostname: this._options.baseUrl,
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
+ );
159
+
160
+ req.on("error", reject);
161
+ req.write(postData);
162
+ req.end();
163
+ });
164
+ }
165
+
166
+ solvingRecaptcha3(url, googleKey, action, score = "0.3", options = {}) {
167
+ return new Promise((resolve, reject) => {
168
+ const postData = JSON.stringify({
169
+ ...options,
170
+ soft_id: this._options.soft_id,
171
+ method: "userrecaptcha",
172
+ version: "v3",
173
+ action,
174
+ min_score: score,
175
+ key: this._options.key,
176
+ pageurl: url,
177
+ googlekey: googleKey,
178
+ json: "1",
179
+ });
180
+
181
+ const req = http.request(
182
+ {
183
+ hostname: this._options.baseUrl,
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
+ );
211
+
212
+ req.on("error", reject);
213
+ req.write(postData);
214
+ req.end();
215
+ });
216
+ }
217
+
218
+ reportBad(id) {
219
+ return new Promise((resolve, reject) => {
220
+ http
221
+ .get(
222
+ {
223
+ hostname: this._options.baseUrl,
224
+ port: 80,
225
+ path: `/res.php?key=${this._options.key}&action=reportbad&id=${id}&json=1`,
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);
241
+ });
242
+ }
243
+
244
+ reportGood(id) {
245
+ return new Promise((resolve, reject) => {
246
+ http
247
+ .get(
248
+ {
249
+ hostname: this._options.baseUrl,
250
+ port: 80,
251
+ path: `/res.php?key=${this._options.key}&action=reportgood&id=${id}&json=1`,
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);
267
+ });
268
+ }
269
+ }
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,11 +1,9 @@
1
1
  {
2
2
  "name": "recognize",
3
- "version": "0.2.1",
4
- "description": "Client for RuCaptcha.com using node.js",
5
- "main": "recognize.js",
6
- "directories": {
7
- "example": "example"
8
- },
3
+ "version": "1.0.0",
4
+ "description": "Client for solving services using node.js",
5
+ "main": "index.js",
6
+ "type": "module",
9
7
  "scripts": {
10
8
  "test": "echo \"Error: no test specified\" && exit 1"
11
9
  },
@@ -16,7 +14,6 @@
16
14
  "keywords": [
17
15
  "captcha",
18
16
  "rucaptcha",
19
- "recaptcha.com",
20
17
  "antigate"
21
18
  ],
22
19
  "author": "kdinisv",
package/.idea/.name DELETED
@@ -1 +0,0 @@
1
- Recognize
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$" />
5
- <orderEntry type="inheritedJdk" />
6
- <orderEntry type="sourceFolder" forTests="false" />
7
- <orderEntry type="library" name="Node.js v0.12.5 Core Modules" level="application" />
8
- </component>
9
- </module>
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptLibraryMappings">
4
- <file url="PROJECT" libraries="{Node.js v0.12.5 Core Modules}" />
5
- <includedPredefinedLibrary name="Node.js Globals" />
6
- <excludedPredefinedLibrary name="HTML" />
7
- <excludedPredefinedLibrary name="HTML5 / EcmaScript 5" />
8
- </component>
9
- </project>
package/.idea/misc.xml DELETED
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectLevelVcsManager" settingsEditedManually="false">
4
- <OptionsSetting value="true" id="Add" />
5
- <OptionsSetting value="true" id="Remove" />
6
- <OptionsSetting value="true" id="Checkout" />
7
- <OptionsSetting value="true" id="Update" />
8
- <OptionsSetting value="true" id="Status" />
9
- <OptionsSetting value="true" id="Edit" />
10
- <ConfirmationsSetting value="0" id="Add" />
11
- <ConfirmationsSetting value="0" id="Remove" />
12
- </component>
13
- <component name="ProjectRootManager" version="2" />
14
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/Recognize.iml" filepath="$PROJECT_DIR$/.idea/Recognize.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
@@ -1,351 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ChangeListManager">
4
- <list default="true" id="1ecfc3a7-6aa8-432c-8b90-ff284535fe70" name="Default" comment="add service antigate">
5
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/jsLibraryMappings.xml" />
6
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/README.md" afterPath="$PROJECT_DIR$/README.md" />
7
- </list>
8
- <ignored path="Recognize.iws" />
9
- <ignored path=".idea/workspace.xml" />
10
- <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
11
- <option name="TRACKING_ENABLED" value="true" />
12
- <option name="SHOW_DIALOG" value="false" />
13
- <option name="HIGHLIGHT_CONFLICTS" value="true" />
14
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
15
- <option name="LAST_RESOLUTION" value="IGNORE" />
16
- </component>
17
- <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
18
- <component name="CreatePatchCommitExecutor">
19
- <option name="PATCH_PATH" value="" />
20
- </component>
21
- <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
22
- <component name="FavoritesManager">
23
- <favorites_list name="Recognize" />
24
- </component>
25
- <component name="FileEditorManager">
26
- <leaf>
27
- <file leaf-file-name="recognize.js" pinned="false" current-in-tab="false">
28
- <entry file="file://$PROJECT_DIR$/recognize.js">
29
- <provider selected="true" editor-type-id="text-editor">
30
- <state vertical-scroll-proportion="0.0">
31
- <caret line="68" column="11" selection-start-line="68" selection-start-column="11" selection-end-line="68" selection-end-column="11" />
32
- <folding />
33
- </state>
34
- </provider>
35
- </entry>
36
- </file>
37
- <file leaf-file-name="package.json" pinned="false" current-in-tab="false">
38
- <entry file="file://$PROJECT_DIR$/package.json">
39
- <provider selected="true" editor-type-id="text-editor">
40
- <state vertical-scroll-proportion="-7.1923075">
41
- <caret line="11" column="17" selection-start-line="11" selection-start-column="17" selection-end-line="11" selection-end-column="17" />
42
- <folding />
43
- </state>
44
- </provider>
45
- </entry>
46
- </file>
47
- <file leaf-file-name="README.md" pinned="false" current-in-tab="true">
48
- <entry file="file://$PROJECT_DIR$/README.md">
49
- <provider selected="true" editor-type-id="text-editor">
50
- <state vertical-scroll-proportion="0.3482309">
51
- <caret line="11" column="38" selection-start-line="11" selection-start-column="38" selection-end-line="11" selection-end-column="38" />
52
- <folding />
53
- </state>
54
- </provider>
55
- <provider editor-type-id="MarkdownPreviewEditor">
56
- <state />
57
- </provider>
58
- </entry>
59
- </file>
60
- <file leaf-file-name="test.js" pinned="false" current-in-tab="false">
61
- <entry file="file://$PROJECT_DIR$/example/test.js">
62
- <provider selected="true" editor-type-id="text-editor">
63
- <state vertical-scroll-proportion="0.0">
64
- <caret line="7" column="33" selection-start-line="7" selection-start-column="33" selection-end-line="7" selection-end-column="33" />
65
- <folding />
66
- </state>
67
- </provider>
68
- </entry>
69
- </file>
70
- </leaf>
71
- </component>
72
- <component name="FileTemplateManagerImpl">
73
- <option name="RECENT_TEMPLATES">
74
- <list>
75
- <option value="JavaScript File" />
76
- </list>
77
- </option>
78
- </component>
79
- <component name="Git.Settings">
80
- <option name="UPDATE_TYPE" value="REBASE" />
81
- <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
82
- </component>
83
- <component name="IdeDocumentHistory">
84
- <option name="CHANGED_PATHS">
85
- <list>
86
- <option value="$PROJECT_DIR$/clients/rucaptcha.js" />
87
- <option value="$PROJECT_DIR$/recognize.js" />
88
- <option value="$PROJECT_DIR$/example/test.js" />
89
- <option value="$PROJECT_DIR$/package.json" />
90
- <option value="$PROJECT_DIR$/README.md" />
91
- </list>
92
- </option>
93
- </component>
94
- <component name="JsBuildToolGruntFileManager" detection-done="true" />
95
- <component name="JsGulpfileManager">
96
- <detection-done>true</detection-done>
97
- </component>
98
- <component name="NamedScopeManager">
99
- <order />
100
- </component>
101
- <component name="ProjectFrameBounds">
102
- <option name="x" value="-8" />
103
- <option name="y" value="-8" />
104
- <option name="width" value="1936" />
105
- <option name="height" value="1056" />
106
- </component>
107
- <component name="ProjectLevelVcsManager" settingsEditedManually="false">
108
- <OptionsSetting value="true" id="Add" />
109
- <OptionsSetting value="true" id="Remove" />
110
- <OptionsSetting value="true" id="Checkout" />
111
- <OptionsSetting value="true" id="Update" />
112
- <OptionsSetting value="true" id="Status" />
113
- <OptionsSetting value="true" id="Edit" />
114
- <ConfirmationsSetting value="0" id="Add" />
115
- <ConfirmationsSetting value="0" id="Remove" />
116
- </component>
117
- <component name="ProjectView">
118
- <navigator currentView="ProjectPane" proportions="" version="1">
119
- <flattenPackages />
120
- <showMembers />
121
- <showModules />
122
- <showLibraryContents />
123
- <hideEmptyPackages />
124
- <abbreviatePackageNames />
125
- <autoscrollToSource />
126
- <autoscrollFromSource />
127
- <sortByType />
128
- </navigator>
129
- <panes>
130
- <pane id="ProjectPane">
131
- <subPane>
132
- <PATH>
133
- <PATH_ELEMENT>
134
- <option name="myItemId" value="Recognize" />
135
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
136
- </PATH_ELEMENT>
137
- </PATH>
138
- <PATH>
139
- <PATH_ELEMENT>
140
- <option name="myItemId" value="Recognize" />
141
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
142
- </PATH_ELEMENT>
143
- <PATH_ELEMENT>
144
- <option name="myItemId" value="Recognize" />
145
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
146
- </PATH_ELEMENT>
147
- </PATH>
148
- </subPane>
149
- </pane>
150
- <pane id="Scratches" />
151
- <pane id="Scope" />
152
- </panes>
153
- </component>
154
- <component name="PropertiesComponent">
155
- <property name="last_opened_file_path" value="$USER_HOME$/Documents/Node.js/steammo" />
156
- <property name="WebServerToolWindowFactoryState" value="false" />
157
- <property name="FullScreen" value="false" />
158
- <property name="settings.editor.selected.configurable" value="project.propVCSSupport.Mappings" />
159
- <property name="settings.editor.splitter.proportion" value="0.2" />
160
- <property name="recentsLimit" value="5" />
161
- <property name="restartRequiresConfirmation" value="true" />
162
- </component>
163
- <component name="RecentsManager">
164
- <key name="CopyFile.RECENT_KEYS">
165
- <recent name="E:\develop\Recognize" />
166
- </key>
167
- </component>
168
- <component name="RunManager" selected="Node.js.Unnamed">
169
- <configuration default="true" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application">
170
- <method />
171
- </configuration>
172
- <configuration default="true" type="DartUnitRunConfigurationType" factoryName="DartUnit">
173
- <method />
174
- </configuration>
175
- <configuration default="true" type="JavaScriptTestRunnerKarma" factoryName="Karma" config-file="">
176
- <envs />
177
- <method />
178
- </configuration>
179
- <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
180
- <method />
181
- </configuration>
182
- <configuration default="true" type="JsTestDriver-test-runner" factoryName="JsTestDriver">
183
- <setting name="configLocationType" value="CONFIG_FILE" />
184
- <setting name="settingsFile" value="" />
185
- <setting name="serverType" value="INTERNAL" />
186
- <setting name="preferredDebugBrowser" value="Chrome" />
187
- <method />
188
- </configuration>
189
- <configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" working-dir="">
190
- <method />
191
- </configuration>
192
- <configuration default="true" type="cucumber.js" factoryName="Cucumber.js">
193
- <option name="cucumberJsArguments" value="" />
194
- <option name="executablePath" />
195
- <option name="filePath" />
196
- <method />
197
- </configuration>
198
- <configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
199
- <node-options />
200
- <gulpfile />
201
- <tasks />
202
- <arguments />
203
- <pass-parent-envs>true</pass-parent-envs>
204
- <envs />
205
- <method />
206
- </configuration>
207
- <configuration default="false" name="Unnamed" type="NodeJSConfigurationType" factoryName="Node.js" path-to-node="C:/Program Files/nodejs/node" path-to-js-file="example/test.js" working-dir="$PROJECT_DIR$">
208
- <method />
209
- </configuration>
210
- <list size="1">
211
- <item index="0" class="java.lang.String" itemvalue="Node.js.Unnamed" />
212
- </list>
213
- </component>
214
- <component name="ShelveChangesManager" show_recycled="false" />
215
- <component name="SvnConfiguration">
216
- <configuration>C:\Users\Zybr\AppData\Roaming\Subversion</configuration>
217
- </component>
218
- <component name="TaskManager">
219
- <task active="true" id="Default" summary="Default task">
220
- <changelist id="1ecfc3a7-6aa8-432c-8b90-ff284535fe70" name="Default" comment="" />
221
- <created>1435610958491</created>
222
- <option name="number" value="Default" />
223
- <updated>1435610958491</updated>
224
- </task>
225
- <task id="LOCAL-00001" summary="Client for RuCaptcha.com using node.js">
226
- <created>1435611001818</created>
227
- <option name="number" value="00001" />
228
- <option name="project" value="LOCAL" />
229
- <updated>1435611001818</updated>
230
- </task>
231
- <task id="LOCAL-00002" summary="Client for RuCaptcha.com using node.js">
232
- <created>1435623391620</created>
233
- <option name="number" value="00002" />
234
- <option name="project" value="LOCAL" />
235
- <updated>1435623391620</updated>
236
- </task>
237
- <task id="LOCAL-00003" summary="add service antigate">
238
- <created>1435698063625</created>
239
- <option name="number" value="00003" />
240
- <option name="project" value="LOCAL" />
241
- <updated>1435698063625</updated>
242
- </task>
243
- <option name="localTasksCounter" value="4" />
244
- <servers />
245
- </component>
246
- <component name="ToolWindowManager">
247
- <frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
248
- <editor active="true" />
249
- <layout>
250
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24973656" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
251
- <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
252
- <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
253
- <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
254
- <window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
255
- <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32972974" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
256
- <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32972974" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
257
- <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
258
- <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32864866" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
259
- <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
260
- <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
261
- <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
262
- <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
263
- <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
264
- <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
265
- <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
266
- <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
267
- <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
268
- </layout>
269
- </component>
270
- <component name="Vcs.Log.UiProperties">
271
- <option name="RECENTLY_FILTERED_USER_GROUPS">
272
- <collection />
273
- </option>
274
- <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
275
- <collection />
276
- </option>
277
- </component>
278
- <component name="VcsContentAnnotationSettings">
279
- <option name="myLimit" value="2678400000" />
280
- </component>
281
- <component name="VcsManagerConfiguration">
282
- <MESSAGE value="Client for RuCaptcha.com using node.js" />
283
- <MESSAGE value="add service antigate" />
284
- <option name="LAST_COMMIT_MESSAGE" value="add service antigate" />
285
- </component>
286
- <component name="XDebuggerManager">
287
- <breakpoint-manager />
288
- <watches-manager />
289
- </component>
290
- <component name="editorHistoryManager">
291
- <entry file="file://$PROJECT_DIR$/recognize.js">
292
- <provider selected="true" editor-type-id="text-editor">
293
- <state vertical-scroll-proportion="0.0">
294
- <caret line="17" column="51" selection-start-line="17" selection-start-column="51" selection-end-line="17" selection-end-column="51" />
295
- <folding />
296
- </state>
297
- </provider>
298
- </entry>
299
- <entry file="file://$PROJECT_DIR$/package.json">
300
- <provider selected="true" editor-type-id="text-editor">
301
- <state vertical-scroll-proportion="0.0">
302
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
303
- <folding />
304
- </state>
305
- </provider>
306
- </entry>
307
- <entry file="file://$PROJECT_DIR$/example/test.js">
308
- <provider selected="true" editor-type-id="text-editor">
309
- <state vertical-scroll-proportion="0.0">
310
- <caret line="7" column="33" selection-start-line="7" selection-start-column="33" selection-end-line="7" selection-end-column="33" />
311
- <folding />
312
- </state>
313
- </provider>
314
- </entry>
315
- <entry file="file://$PROJECT_DIR$/recognize.js">
316
- <provider selected="true" editor-type-id="text-editor">
317
- <state vertical-scroll-proportion="0.0">
318
- <caret line="68" column="11" selection-start-line="68" selection-start-column="11" selection-end-line="68" selection-end-column="11" />
319
- <folding />
320
- </state>
321
- </provider>
322
- </entry>
323
- <entry file="file://$PROJECT_DIR$/.idea/jsLibraryMappings.xml">
324
- <provider selected="true" editor-type-id="text-editor">
325
- <state vertical-scroll-proportion="0.0">
326
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
327
- <folding />
328
- </state>
329
- </provider>
330
- </entry>
331
- <entry file="file://$PROJECT_DIR$/package.json">
332
- <provider selected="true" editor-type-id="text-editor">
333
- <state vertical-scroll-proportion="-7.1923075">
334
- <caret line="11" column="17" selection-start-line="11" selection-start-column="17" selection-end-line="11" selection-end-column="17" />
335
- <folding />
336
- </state>
337
- </provider>
338
- </entry>
339
- <entry file="file://$PROJECT_DIR$/README.md">
340
- <provider selected="true" editor-type-id="text-editor">
341
- <state vertical-scroll-proportion="0.3482309">
342
- <caret line="11" column="38" selection-start-line="11" selection-start-column="38" selection-end-line="11" selection-end-column="38" />
343
- <folding />
344
- </state>
345
- </provider>
346
- <provider editor-type-id="MarkdownPreviewEditor">
347
- <state />
348
- </provider>
349
- </entry>
350
- </component>
351
- </project>
package/recognize.js DELETED
@@ -1,131 +0,0 @@
1
- module.exports = Recognize;
2
-
3
- var http = require('http');
4
- var uri = require('url');
5
- var querystring = require('querystring');
6
-
7
- function Recognize(type, settings)
8
- {
9
- this.type = type;
10
- switch(type)
11
- {
12
- case 'rucaptcha':
13
- this.baseUrl = 'http://rucaptcha.com';
14
- this.id = 768;
15
- break;
16
- case 'antigate':
17
- this.baseUrl = 'http://anti-captcha.com';
18
- this.id;
19
- break;
20
- default :
21
- throw new Error('invalid type');
22
-
23
- }
24
- this.settings = settings || {};
25
- this.key = this.settings.key || this.key;
26
- require('events').EventEmitter.call(this);
27
- }
28
-
29
- require('util').inherits(Recognize, require('events').EventEmitter);
30
-
31
- Recognize.prototype = {
32
- solving: function(file, settings, cb){
33
- if(typeof settings == 'function')
34
- {
35
- cb = settings;
36
- settings = {};
37
- }
38
- settings = settings || this.settings || {};
39
-
40
- var self = this;
41
- var options = uri.parse(this.baseUrl + '/in.php');
42
- options.method = 'POST';
43
- options.headers = {
44
- 'Content-Type': 'application/x-www-form-urlencoded'
45
- };
46
- var req = http.request(options, function(res){
47
- var body = [];
48
- res.on('data', function (chunk) {
49
- body.push(chunk);
50
- });
51
- res.on('end', function () {
52
- var answer = body.toString().split('|');
53
- //console.log(answer);
54
- switch (answer[0])
55
- {
56
- case 'OK':
57
- get(self.baseUrl, self.key, answer[1], function(err, code){
58
- cb(err, answer[1], code);
59
- });
60
- break;
61
- default :
62
- cb(answer[0]);
63
- }
64
- });
65
- });
66
-
67
- req.on('error', function(e) {
68
- console.error(e);
69
- });
70
- settings.soft_id = this.id;
71
- settings.method = 'base64';
72
- settings.key = this.key;
73
- settings.body = file.toString('base64');
74
- req.write(querystring.stringify(settings));
75
- req.end();
76
- },
77
- balanse: function(cb){
78
- var self = this;
79
-
80
- http.get(this.baseUrl + '/res.php?key=' + self.key + '&action=getbalance', function(res){
81
- var body = [];
82
- res.on('data', function (chunk) {
83
- body.push(chunk);
84
- });
85
- res.on('end', function () {
86
- cb(body.toString());
87
- });
88
- }).on('error', function(err){
89
- console.error(err);
90
- });
91
- },
92
- report: function(id, cb)
93
- {
94
- var self = this;
95
- http.get(this.baseUrl + '/res.php?key=' + self.key + '&action=reportbad&id=' + id, function(res){
96
- var body = [];
97
- res.on('data', function (chunk) {
98
- body.push(chunk);
99
- });
100
- res.on('end', function () {
101
- cb(null, body.toString());
102
- });
103
- }).on('error', function(err){
104
- console.error(err);
105
- });
106
- }
107
- };
108
-
109
- function get(baseUrl, key, id, cb){
110
- http.get(baseUrl + '/res.php?key=' + key + '&action=get&id=' + id, function(res){
111
- var body = [];
112
- res.on('data', function (chunk) {
113
- body.push(chunk);
114
- });
115
- res.on('end', function () {
116
- var answer = body.toString().split('|');
117
- switch(answer[0]){
118
- case 'OK':
119
- cb(null, answer[1]);
120
- break;
121
- case 'CAPCHA_NOT_READY':
122
- setTimeout(get, 1000, baseUrl, key, id, cb);
123
- break;
124
- default :
125
- cb(answer[0], null);
126
- }
127
- });
128
- }).on('error', function(err){
129
- console.error(err);
130
- });
131
- };