easy-captcha-python 0.1.0__tar.gz → 1.0.0__tar.gz
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.
- {easy_captcha_python-0.1.0/easy_captcha_python.egg-info → easy_captcha_python-1.0.0}/PKG-INFO +122 -114
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/README.md +420 -413
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0/easy_captcha_python.egg-info}/PKG-INFO +122 -114
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/pyproject.toml +6 -5
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/LICENSE +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/MANIFEST.in +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/__init__.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/base/__init__.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/base/arithmetic_captcha_abstract.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/base/captcha.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/base/chinese_captcha_abstract.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/base/randoms.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/captcha/__init__.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/captcha/arithmetic_captcha.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/captcha/chinese_captcha.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/captcha/chinese_gif_captcha.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/captcha/gif_captcha.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/captcha/spec_captcha.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/constants.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/fonts/actionj.ttf +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/fonts/epilog.ttf +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/fonts/fresnel.ttf +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/fonts/headache.ttf +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/fonts/lexo.ttf +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/fonts/prefix.ttf +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/fonts/progbot.ttf +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/fonts/ransom.ttf +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/fonts/robot.ttf +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha/fonts/scandal.ttf +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha_python.egg-info/SOURCES.txt +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha_python.egg-info/dependency_links.txt +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha_python.egg-info/requires.txt +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/easy_captcha_python.egg-info/top_level.txt +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/setup.cfg +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/setup.py +0 -0
- {easy_captcha_python-0.1.0 → easy_captcha_python-1.0.0}/tests/test_spec_captcha.py +0 -0
{easy_captcha_python-0.1.0/easy_captcha_python.egg-info → easy_captcha_python-1.0.0}/PKG-INFO
RENAMED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: easy-captcha-python
|
|
3
|
-
Version:
|
|
4
|
-
Summary: Python
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python graphic captcha generation library supporting GIF, Chinese characters, arithmetic and more
|
|
5
5
|
Author-email: Kevin Roo <mostvegetableplayer@gmail.com>
|
|
6
6
|
License: Apache-2.0
|
|
7
|
-
Project-URL: Homepage, https://
|
|
8
|
-
Project-URL: Repository, https://
|
|
9
|
-
|
|
7
|
+
Project-URL: Homepage, https://github.com/Savlgoodman/EasyCaptcha-Python
|
|
8
|
+
Project-URL: Repository, https://github.com/Savlgoodman/EasyCaptcha-Python
|
|
9
|
+
Project-URL: Documentation, https://github.com/Savlgoodman/EasyCaptcha-Python/blob/master/docs/EASYCAPTCHA-PYTHON-USAGE.md
|
|
10
|
+
Keywords: captcha,verification code,gif,image
|
|
10
11
|
Classifier: Development Status :: 4 - Beta
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
12
13
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
@@ -35,103 +36,105 @@ Dynamic: requires-python
|
|
|
35
36
|

|
|
36
37
|

|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
> 🌐 **Language** | [English](README.md) | [中文](README_zh.md)
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
Python graphic captcha generation library supporting GIF, Chinese characters, arithmetic, and other types. Suitable for Python Web, desktop applications, and more.
|
|
42
|
+
|
|
43
|
+
This is a Python implementation of the [EasyCaptcha](https://github.com/whvcse/EasyCaptcha) Java version.
|
|
41
44
|
|
|
42
45
|
---
|
|
43
46
|
|
|
44
|
-
## 1
|
|
47
|
+
## 1. Introduction
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
Python graphic captcha supporting GIF, Chinese characters, arithmetic, and other types. Compatible with Flask, Django, FastAPI, and other web frameworks.
|
|
47
50
|
|
|
48
51
|
---
|
|
49
52
|
|
|
50
|
-
## 2
|
|
53
|
+
## 2. Demo
|
|
51
54
|
|
|
52
|
-
**PNG
|
|
55
|
+
**PNG Type:**
|
|
53
56
|
|
|
54
|
-

|
|
55
58
|
  
|
|
56
|
-

|
|
57
60
|
  
|
|
58
|
-

|
|
59
62
|
|
|
60
|
-
**GIF
|
|
63
|
+
**GIF Type:**
|
|
61
64
|
|
|
62
|
-

|
|
63
66
|
  
|
|
64
|
-

|
|
65
68
|
  
|
|
66
|
-

|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
**Arithmetic Type:**
|
|
69
72
|
|
|
70
|
-

|
|
71
74
|
  
|
|
72
|
-

|
|
73
76
|
  
|
|
74
|
-

|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
**Chinese Type:**
|
|
77
80
|
|
|
78
|
-

|
|
79
82
|
  
|
|
80
|
-

|
|
81
84
|
  
|
|
82
|
-

|
|
83
86
|
|
|
84
|
-
|
|
87
|
+
**Built-in Fonts:**
|
|
85
88
|
|
|
86
|
-

|
|
87
90
|
  
|
|
88
|
-

|
|
89
92
|
  
|
|
90
|
-

|
|
91
94
|
|
|
92
95
|
---
|
|
93
96
|
|
|
94
|
-
## 3
|
|
97
|
+
## 3. Installation
|
|
95
98
|
|
|
96
|
-
### 3.1
|
|
99
|
+
### 3.1. Install via pip
|
|
97
100
|
|
|
98
101
|
```bash
|
|
99
102
|
pip install easy-captcha-python
|
|
100
103
|
```
|
|
101
104
|
|
|
102
|
-
### 3.2
|
|
105
|
+
### 3.2. Install from source
|
|
103
106
|
|
|
104
107
|
```bash
|
|
105
|
-
git clone https://github.com/
|
|
108
|
+
git clone https://github.com/Savlgoodman/EasyCaptcha-Python
|
|
106
109
|
cd easy-captcha-python
|
|
107
110
|
pip install -e .
|
|
108
111
|
```
|
|
109
112
|
|
|
110
113
|
---
|
|
111
114
|
|
|
112
|
-
## 4
|
|
115
|
+
## 4. Usage
|
|
113
116
|
|
|
114
|
-
### 4.1
|
|
117
|
+
### 4.1. Quick Start
|
|
115
118
|
|
|
116
119
|
```python
|
|
117
120
|
from easy_captcha import SpecCaptcha
|
|
118
121
|
from io import BytesIO
|
|
119
122
|
|
|
120
|
-
#
|
|
123
|
+
# Three parameters: width, height, character count
|
|
121
124
|
captcha = SpecCaptcha(130, 48, 5)
|
|
122
125
|
|
|
123
|
-
#
|
|
126
|
+
# Get captcha text
|
|
124
127
|
code = captcha.text()
|
|
125
|
-
print(f"
|
|
128
|
+
print(f"Captcha: {code}")
|
|
126
129
|
|
|
127
|
-
#
|
|
130
|
+
# Write to file
|
|
128
131
|
with open('captcha.png', 'wb') as f:
|
|
129
132
|
stream = BytesIO()
|
|
130
133
|
captcha.out(stream)
|
|
131
134
|
f.write(stream.getvalue())
|
|
132
135
|
```
|
|
133
136
|
|
|
134
|
-
### 4.2
|
|
137
|
+
### 4.2. Use with Flask
|
|
135
138
|
|
|
136
139
|
```python
|
|
137
140
|
from flask import Flask, session, make_response
|
|
@@ -143,12 +146,12 @@ app.secret_key = 'your-secret-key'
|
|
|
143
146
|
|
|
144
147
|
@app.route('/captcha')
|
|
145
148
|
def captcha():
|
|
146
|
-
#
|
|
149
|
+
# Create captcha
|
|
147
150
|
cap = SpecCaptcha(130, 48, 5)
|
|
148
|
-
#
|
|
151
|
+
# Store captcha text in session
|
|
149
152
|
session['captcha'] = cap.text().lower()
|
|
150
153
|
|
|
151
|
-
#
|
|
154
|
+
# Output image
|
|
152
155
|
stream = BytesIO()
|
|
153
156
|
cap.out(stream)
|
|
154
157
|
|
|
@@ -158,19 +161,19 @@ def captcha():
|
|
|
158
161
|
|
|
159
162
|
@app.route('/verify/<code>')
|
|
160
163
|
def verify(code):
|
|
161
|
-
#
|
|
164
|
+
# Get captcha from session
|
|
162
165
|
if code.lower() == session.get('captcha'):
|
|
163
|
-
return '
|
|
164
|
-
return '
|
|
166
|
+
return 'Verification successful'
|
|
167
|
+
return 'Verification failed'
|
|
165
168
|
```
|
|
166
169
|
|
|
167
|
-
|
|
170
|
+
Frontend HTML:
|
|
168
171
|
|
|
169
172
|
```html
|
|
170
173
|
<img src="/captcha" width="130px" height="48px" />
|
|
171
174
|
```
|
|
172
175
|
|
|
173
|
-
### 4.3
|
|
176
|
+
### 4.3. Use with Django
|
|
174
177
|
|
|
175
178
|
```python
|
|
176
179
|
from django.http import HttpResponse
|
|
@@ -179,17 +182,17 @@ from io import BytesIO
|
|
|
179
182
|
|
|
180
183
|
def captcha(request):
|
|
181
184
|
cap = SpecCaptcha(130, 48, 5)
|
|
182
|
-
#
|
|
185
|
+
# Store captcha text in session
|
|
183
186
|
request.session['captcha'] = cap.text().lower()
|
|
184
187
|
|
|
185
|
-
#
|
|
188
|
+
# Output image
|
|
186
189
|
stream = BytesIO()
|
|
187
190
|
cap.out(stream)
|
|
188
191
|
|
|
189
192
|
return HttpResponse(stream.getvalue(), content_type='image/png')
|
|
190
193
|
```
|
|
191
194
|
|
|
192
|
-
### 4.4
|
|
195
|
+
### 4.4. Use with FastAPI
|
|
193
196
|
|
|
194
197
|
```python
|
|
195
198
|
from fastapi import FastAPI, Response
|
|
@@ -209,16 +212,16 @@ async def captcha():
|
|
|
209
212
|
return Response(content=stream.getvalue(), media_type="image/png")
|
|
210
213
|
```
|
|
211
214
|
|
|
212
|
-
### 4.5
|
|
215
|
+
### 4.5. Frontend-Backend Separated Projects
|
|
213
216
|
|
|
214
|
-
|
|
217
|
+
For frontend-backend separated projects, it is recommended to return base64 encoded images:
|
|
215
218
|
|
|
216
219
|
```python
|
|
217
220
|
from flask import Flask, jsonify, request
|
|
218
221
|
import uuid
|
|
219
222
|
|
|
220
223
|
app = Flask(__name__)
|
|
221
|
-
#
|
|
224
|
+
# Using dictionary as simulation, Redis is recommended for production
|
|
222
225
|
captcha_store = {}
|
|
223
226
|
|
|
224
227
|
@app.route('/captcha')
|
|
@@ -229,10 +232,10 @@ def get_captcha():
|
|
|
229
232
|
code = cap.text().lower()
|
|
230
233
|
key = str(uuid.uuid4())
|
|
231
234
|
|
|
232
|
-
#
|
|
235
|
+
# Store captcha (recommend storing in Redis with expiration in production)
|
|
233
236
|
captcha_store[key] = code
|
|
234
237
|
|
|
235
|
-
#
|
|
238
|
+
# Return key and base64 image
|
|
236
239
|
return jsonify({
|
|
237
240
|
'key': key,
|
|
238
241
|
'image': cap.to_base64()
|
|
@@ -244,22 +247,22 @@ def login():
|
|
|
244
247
|
ver_key = data.get('verKey')
|
|
245
248
|
ver_code = data.get('verCode', '').lower()
|
|
246
249
|
|
|
247
|
-
#
|
|
250
|
+
# Verify captcha
|
|
248
251
|
if ver_code == captcha_store.get(ver_key):
|
|
249
|
-
#
|
|
252
|
+
# Remove after successful verification
|
|
250
253
|
captcha_store.pop(ver_key, None)
|
|
251
254
|
return jsonify({'success': True})
|
|
252
|
-
return jsonify({'success': False, 'message': '
|
|
255
|
+
return jsonify({'success': False, 'message': 'Captcha error'})
|
|
253
256
|
```
|
|
254
257
|
|
|
255
|
-
|
|
258
|
+
Frontend example:
|
|
256
259
|
|
|
257
260
|
```html
|
|
258
261
|
<img id="verImg" width="130px" height="48px" />
|
|
259
262
|
|
|
260
263
|
<script>
|
|
261
264
|
var verKey;
|
|
262
|
-
//
|
|
265
|
+
// Fetch captcha
|
|
263
266
|
fetch("/captcha")
|
|
264
267
|
.then((res) => res.json())
|
|
265
268
|
.then((data) => {
|
|
@@ -267,7 +270,7 @@ def login():
|
|
|
267
270
|
document.getElementById("verImg").src = data.image;
|
|
268
271
|
});
|
|
269
272
|
|
|
270
|
-
//
|
|
273
|
+
// Login
|
|
271
274
|
fetch("/login", {
|
|
272
275
|
method: "POST",
|
|
273
276
|
headers: { "Content-Type": "application/json" },
|
|
@@ -285,9 +288,9 @@ def login():
|
|
|
285
288
|
|
|
286
289
|
---
|
|
287
290
|
|
|
288
|
-
## 5
|
|
291
|
+
## 5. More Settings
|
|
289
292
|
|
|
290
|
-
### 5.1
|
|
293
|
+
### 5.1. Captcha Types
|
|
291
294
|
|
|
292
295
|
```python
|
|
293
296
|
from easy_captcha import (
|
|
@@ -295,47 +298,48 @@ from easy_captcha import (
|
|
|
295
298
|
ChineseGifCaptcha, ArithmeticCaptcha
|
|
296
299
|
)
|
|
297
300
|
|
|
298
|
-
# PNG
|
|
301
|
+
# PNG type
|
|
299
302
|
captcha = SpecCaptcha(130, 48, 5)
|
|
300
|
-
code = captcha.text() #
|
|
301
|
-
chars = captcha.text_char() #
|
|
303
|
+
code = captcha.text() # Get captcha text
|
|
304
|
+
chars = captcha.text_char() # Get captcha character array
|
|
302
305
|
|
|
303
|
-
# GIF
|
|
306
|
+
# GIF type
|
|
304
307
|
captcha = GifCaptcha(130, 48, 5)
|
|
305
308
|
|
|
306
|
-
#
|
|
309
|
+
# Chinese type
|
|
307
310
|
captcha = ChineseCaptcha(130, 48, 4)
|
|
308
311
|
|
|
309
|
-
#
|
|
312
|
+
# Chinese GIF type
|
|
310
313
|
captcha = ChineseGifCaptcha(130, 48, 4)
|
|
311
314
|
|
|
312
|
-
#
|
|
315
|
+
# Arithmetic type
|
|
313
316
|
captcha = ArithmeticCaptcha(130, 48, 2)
|
|
314
|
-
captcha.len = 3 #
|
|
315
|
-
formula = captcha.get_arithmetic_string() #
|
|
316
|
-
result = captcha.text() #
|
|
317
|
+
captcha.len = 3 # Number of digits for arithmetic, default is two
|
|
318
|
+
formula = captcha.get_arithmetic_string() # Get arithmetic formula: 3+2=?
|
|
319
|
+
result = captcha.text() # Get result: 5
|
|
317
320
|
|
|
318
|
-
#
|
|
321
|
+
# Output captcha
|
|
319
322
|
from io import BytesIO
|
|
320
323
|
stream = BytesIO()
|
|
321
324
|
captcha.out(stream)
|
|
322
325
|
```
|
|
323
326
|
|
|
324
|
-
>
|
|
325
|
-
>
|
|
327
|
+
> Note:<br/>
|
|
328
|
+
>  For arithmetic captcha, `len` represents the number of digits in the operation, while for other captchas `len` represents the number of characters. The `text()` method for arithmetic captcha returns the result of the formula.
|
|
329
|
+
> For arithmetic captcha, you should store the result in session, not the formula itself.
|
|
326
330
|
|
|
327
|
-
### 5.2
|
|
331
|
+
### 5.2. Character Types
|
|
328
332
|
|
|
329
|
-
|
|
|
330
|
-
| :----------------- |
|
|
331
|
-
| TYPE_DEFAULT |
|
|
332
|
-
| TYPE_ONLY_NUMBER |
|
|
333
|
-
| TYPE_ONLY_CHAR |
|
|
334
|
-
| TYPE_ONLY_UPPER |
|
|
335
|
-
| TYPE_ONLY_LOWER |
|
|
336
|
-
| TYPE_NUM_AND_UPPER |
|
|
333
|
+
| Type | Description |
|
|
334
|
+
| :----------------- | :-------------------- |
|
|
335
|
+
| TYPE_DEFAULT | Numbers and letters |
|
|
336
|
+
| TYPE_ONLY_NUMBER | Numbers only |
|
|
337
|
+
| TYPE_ONLY_CHAR | Letters only |
|
|
338
|
+
| TYPE_ONLY_UPPER | Uppercase only |
|
|
339
|
+
| TYPE_ONLY_LOWER | Lowercase only |
|
|
340
|
+
| TYPE_NUM_AND_UPPER | Numbers and uppercase |
|
|
337
341
|
|
|
338
|
-
|
|
342
|
+
Usage:
|
|
339
343
|
|
|
340
344
|
```python
|
|
341
345
|
from easy_captcha import SpecCaptcha, TYPE_ONLY_NUMBER
|
|
@@ -344,14 +348,14 @@ captcha = SpecCaptcha(130, 48, 5)
|
|
|
344
348
|
captcha.char_type = TYPE_ONLY_NUMBER
|
|
345
349
|
```
|
|
346
350
|
|
|
347
|
-
>
|
|
351
|
+
> Only effective for `SpecCaptcha` and `GifCaptcha`.
|
|
348
352
|
|
|
349
|
-
### 5.3
|
|
353
|
+
### 5.3. Font Settings
|
|
350
354
|
|
|
351
|
-
|
|
355
|
+
Built-in fonts:
|
|
352
356
|
|
|
353
|
-
|
|
|
354
|
-
| :------ |
|
|
357
|
+
| Font | Preview |
|
|
358
|
+
| :------ | :------------------------------------------- |
|
|
355
359
|
| FONT_1 |  |
|
|
356
360
|
| FONT_2 |  |
|
|
357
361
|
| FONT_3 |  |
|
|
@@ -363,22 +367,22 @@ captcha.char_type = TYPE_ONLY_NUMBER
|
|
|
363
367
|
| FONT_9 |  |
|
|
364
368
|
| FONT_10 |  |
|
|
365
369
|
|
|
366
|
-
|
|
370
|
+
Usage:
|
|
367
371
|
|
|
368
372
|
```python
|
|
369
373
|
from easy_captcha import SpecCaptcha, FONT_1, FONT_2
|
|
370
374
|
|
|
371
375
|
captcha = SpecCaptcha(130, 48, 5)
|
|
372
376
|
|
|
373
|
-
#
|
|
377
|
+
# Set built-in font
|
|
374
378
|
captcha.set_font(FONT_1, size=32)
|
|
375
379
|
|
|
376
|
-
#
|
|
380
|
+
# You can also use system fonts (requires PIL.ImageFont support)
|
|
377
381
|
from PIL import ImageFont
|
|
378
382
|
captcha._font = ImageFont.truetype("arial.ttf", 32)
|
|
379
383
|
```
|
|
380
384
|
|
|
381
|
-
### 5.4
|
|
385
|
+
### 5.4. Output base64
|
|
382
386
|
|
|
383
387
|
```python
|
|
384
388
|
from easy_captcha import SpecCaptcha
|
|
@@ -386,11 +390,11 @@ from easy_captcha import SpecCaptcha
|
|
|
386
390
|
captcha = SpecCaptcha(130, 48, 5)
|
|
387
391
|
base64_str = captcha.to_base64()
|
|
388
392
|
|
|
389
|
-
#
|
|
390
|
-
base64_str = captcha.to_base64("") #
|
|
393
|
+
# If you don't want the base64 header "data:image/png;base64,"
|
|
394
|
+
base64_str = captcha.to_base64("") # Just pass an empty parameter
|
|
391
395
|
```
|
|
392
396
|
|
|
393
|
-
### 5.5
|
|
397
|
+
### 5.5. Output to File
|
|
394
398
|
|
|
395
399
|
```python
|
|
396
400
|
from easy_captcha import SpecCaptcha
|
|
@@ -398,7 +402,7 @@ from io import BytesIO
|
|
|
398
402
|
|
|
399
403
|
captcha = SpecCaptcha(130, 48, 5)
|
|
400
404
|
|
|
401
|
-
#
|
|
405
|
+
# Write to file
|
|
402
406
|
with open('captcha.png', 'wb') as f:
|
|
403
407
|
stream = BytesIO()
|
|
404
408
|
captcha.out(stream)
|
|
@@ -407,39 +411,43 @@ with open('captcha.png', 'wb') as f:
|
|
|
407
411
|
|
|
408
412
|
---
|
|
409
413
|
|
|
410
|
-
## 6
|
|
414
|
+
## 6. Complete Examples
|
|
411
415
|
|
|
412
|
-
|
|
416
|
+
Check the `examples/` directory for more examples:
|
|
413
417
|
|
|
414
|
-
- `basic_usage.py` -
|
|
415
|
-
- `all_types_demo.py` -
|
|
418
|
+
- `basic_usage.py` - Basic usage example
|
|
419
|
+
- `all_types_demo.py` - All captcha types demo
|
|
416
420
|
|
|
417
|
-
|
|
421
|
+
Run examples:
|
|
418
422
|
|
|
419
423
|
```bash
|
|
420
|
-
#
|
|
424
|
+
# Run basic example
|
|
421
425
|
python examples/basic_usage.py
|
|
422
426
|
|
|
423
|
-
#
|
|
427
|
+
# Run full demo
|
|
424
428
|
python examples/all_types_demo.py
|
|
425
429
|
```
|
|
426
430
|
|
|
427
|
-
|
|
431
|
+
All generated captcha images will be saved to the `./out/` directory.
|
|
428
432
|
|
|
429
433
|
---
|
|
430
434
|
|
|
431
|
-
## 7
|
|
435
|
+
## 7. License
|
|
432
436
|
|
|
433
437
|
Apache License 2.0
|
|
434
438
|
|
|
435
439
|
---
|
|
436
440
|
|
|
437
|
-
## 8
|
|
441
|
+
## 8. Acknowledgments
|
|
438
442
|
|
|
439
|
-
|
|
443
|
+
This project is a Python implementation of [EasyCaptcha](https://github.com/whvcse/EasyCaptcha).
|
|
440
444
|
|
|
441
445
|
---
|
|
442
446
|
|
|
443
|
-
## 9
|
|
447
|
+
## 9. Contributing
|
|
448
|
+
|
|
449
|
+
Issues and Pull Requests are welcome!
|
|
450
|
+
|
|
451
|
+
## 10. References
|
|
444
452
|
|
|
445
|
-
|
|
453
|
+
For more detailed documentation, please refer to the [Usage Guide](https://github.com/Savlgoodman/EasyCaptcha-Python/blob/master/docs/EASYCAPTCHA-PYTHON-USAGE.md).
|