Skip to content

Commit cb1d761

Browse files
author
2captcha
authored
Merge pull request #29 from 2captcha/1.1.1
v1.1.1
2 parents 661d46d + 47d5a50 commit cb1d761

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ Below you can find basic examples for every captcha type. Check out [examples di
9090
To bypass a normal captcha (distorted text on image) use the following method. This method also can be used to recognize any text on the image.
9191
```python
9292
result = solver.normal('path/to/captcha.jpg', param1=..., ...)
93+
# OR
94+
result = solver.normal('https://site-with-captcha.com/path/to/captcha.jpg', param1=..., ...)
9395
```
9496

9597
### Text Captcha

setup.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
#!/usr/bin/env python3
22

33
from setuptools import setup, find_packages
4-
from twocaptcha import __version__
4+
import re
55

66
with open("README.md", "r") as fh:
77
long_description = fh.read()
88

9+
10+
def get_version():
11+
with open('twocaptcha/__init__.py', 'r') as f:
12+
return re.search(r'__version__ = ["\'](.*?)["\']', f.read()).group(1)
13+
14+
915
setup(name='2captcha-python',
10-
version=__version__,
16+
version=get_version(),
1117
description='Python module for easy integration with 2Captcha API',
1218
long_description=long_description,
1319
long_description_content_type="text/markdown",

twocaptcha/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .solver import (TwoCaptcha, SolverExceptions, ValidationException,
33
NetworkException, ApiException, TimeoutException)
44

5-
__version__ = '1.1.0'
5+
__version__ = '1.1.1'

twocaptcha/solver.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os, sys
44
import time
5+
import requests
56

67
try:
78
from .api import ApiClient
@@ -55,7 +56,7 @@ def normal(self, file, **kwargs):
5556
Wrapper for solving normal captcha (image)
5657
5758
Required:
58-
file (image or base64)
59+
file (image, base64, or url)
5960
6061
Optional params:
6162
@@ -432,6 +433,12 @@ def get_method(self, file):
432433

433434
if not '.' in file and len(file) > 50:
434435
return {'method': 'base64', 'body': file}
436+
437+
if file.startswith('http'):
438+
img_resp = requests.get(file)
439+
if img_resp.status_code != 200:
440+
raise ValidationException(f'File could not be downloaded from url: {file}')
441+
return {'method': 'base64', 'body': b64encode(img_resp.content).decode('utf-8')}
435442

436443
if not os.path.exists(file):
437444
raise ValidationException(f'File not found: {file}')

0 commit comments

Comments
 (0)