Skip to content

Commit 36fbb40

Browse files
ad-mAdam Dobrawyclaude
authored
Switch README from RST to Markdown (#126)
Markdown is the dominant format on GitHub, renders natively, and is easier for contributors to edit. Inline the previously-included content into the Sphinx docs since they remain RST-based. Co-authored-by: Adam Dobrawy <naczelnik@jawne.info.pl> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 11b67b4 commit 36fbb40

5 files changed

Lines changed: 357 additions & 244 deletions

File tree

README.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# python-anticaptcha
2+
3+
[![Build Status](https://github.com/ad-m/python-anticaptcha/workflows/Python%20package/badge.svg)](https://github.com/ad-m/python-anticaptcha/actions?workflow=Python+package)
4+
[![PyPI](https://img.shields.io/pypi/v/python-anticaptcha.svg)](https://pypi.org/project/python-anticaptcha/)
5+
[![Chat](https://badges.gitter.im/python-anticaptcha/Lobby.svg)](https://gitter.im/python-anticaptcha/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
6+
[![Python compatibility](https://img.shields.io/pypi/pyversions/python-anticaptcha.svg)](https://github.com/ad-m/python-anticaptcha/blob/master/setup.py)
7+
8+
Client library for solve captchas with [Anticaptcha.com support](http://getcaptchasolution.com/i1hvnzdymd).
9+
The library requires Python >= 3.9.
10+
11+
The library is cyclically and automatically tested for proper operation. We are constantly making the best efforts for its effective operation.
12+
13+
In case of any problems with integration - [read the documentation](http://python-anticaptcha.readthedocs.io/en/latest/), [create an issue](https://github.com/ad-m/python-anticaptcha/issues/new), use [Gitter](https://gitter.im/python-anticaptcha/Lobby) or contact privately.
14+
15+
## Getting Started
16+
17+
Install as standard Python package using:
18+
19+
```
20+
pip install python-anticaptcha
21+
```
22+
23+
## Usage
24+
25+
To use this library do you need [Anticaptcha.com](http://getcaptchasolution.com/p9bwplkicx) API key.
26+
27+
You can pass the key explicitly or set the `ANTICAPTCHA_API_KEY` environment variable:
28+
29+
```python
30+
# Explicit key
31+
client = AnticaptchaClient("my-api-key")
32+
33+
# Or set ANTICAPTCHA_API_KEY environment variable
34+
client = AnticaptchaClient()
35+
```
36+
37+
### Solve recaptcha
38+
39+
Example snippet for Recaptcha:
40+
41+
```python
42+
from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask
43+
44+
api_key = '174faff8fbc769e94a5862391ecfd010'
45+
site_key = '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-' # grab from site
46+
url = 'https://www.google.com/recaptcha/api2/demo'
47+
48+
client = AnticaptchaClient(api_key)
49+
task = NoCaptchaTaskProxylessTask(url, site_key)
50+
job = client.create_task(task)
51+
job.join()
52+
print(job.get_solution_response())
53+
```
54+
55+
The full integration example is available in file `examples/recaptcha.py`.
56+
57+
If you only process few page many times to increase reliability, you can specify
58+
whether the captcha is visible or not. This parameter is not required, as is the
59+
system detects invisible sitekeys automatically, and needs several recursive
60+
measures for automated training and analysis. For provide that pass
61+
`is_invisible` parameter to `NoCaptchaTaskProxylessTask` or `NoCaptchaTask` eg.:
62+
63+
```python
64+
from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask
65+
66+
api_key = '174faff8fbc769e94a5862391ecfd010'
67+
site_key = '6Lc-0DYUAAAAAOPM3RGobCfKjIE5STmzvZfHbbNx' # grab from site
68+
url = 'https://losangeles.craigslist.org/lac/kid/d/housekeeper-sitting-pet-care/6720136191.html'
69+
70+
client = AnticaptchaClient(api_key)
71+
task = NoCaptchaTaskProxylessTask(url, site_key, is_invisible=True)
72+
job = client.create_task(task)
73+
job.join()
74+
print(job.get_solution_response())
75+
```
76+
77+
### Solve text captcha
78+
79+
Example snippet for text captcha:
80+
81+
```python
82+
from python_anticaptcha import AnticaptchaClient, ImageToTextTask
83+
84+
api_key = '174faff8fbc769e94a5862391ecfd010'
85+
captcha_fp = open('examples/captcha_ms.jpeg', 'rb')
86+
client = AnticaptchaClient(api_key)
87+
task = ImageToTextTask(captcha_fp)
88+
job = client.create_task(task)
89+
job.join()
90+
print(job.get_captcha_text())
91+
```
92+
93+
### Solve funcaptcha
94+
95+
Example snippet for funcaptcha:
96+
97+
```python
98+
from python_anticaptcha import AnticaptchaClient, FunCaptchaTask, Proxy
99+
UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 ' \
100+
'(KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
101+
102+
api_key = '174faff8fbc769e94a5862391ecfd010'
103+
site_key = 'DE0B0BB7-1EE4-4D70-1853-31B835D4506B' # grab from site
104+
url = 'https://www.google.com/recaptcha/api2/demo'
105+
proxy = Proxy.parse_url("socks5://login:password@123.123.123.123:1080")
106+
107+
client = AnticaptchaClient(api_key)
108+
task = FunCaptchaTask(url, site_key, user_agent=UA, **proxy.to_kwargs())
109+
job = client.create_task(task)
110+
job.join()
111+
print(job.get_token_response())
112+
```
113+
114+
### Report incorrect image
115+
116+
Example snippet for reporting an incorrect image task:
117+
118+
```python
119+
from python_anticaptcha import AnticaptchaClient, ImageToTextTask
120+
121+
api_key = '174faff8fbc769e94a5862391ecfd010'
122+
captcha_fp = open('examples/captcha_ms.jpeg', 'rb')
123+
client = AnticaptchaClient(api_key)
124+
task = ImageToTextTask(captcha_fp)
125+
job = client.create_task(task)
126+
job.join()
127+
print(job.get_captcha_text())
128+
job.report_incorrect_image()
129+
```
130+
131+
### Setup proxy
132+
133+
The library is not responsible for managing the proxy server. However, we point to
134+
the possibility of simply launching such a server by:
135+
136+
```
137+
pip install mitmproxy
138+
mitmweb -p 9190 -b 0.0.0.0 --ignore '.' --socks
139+
```
140+
141+
Next to in your application use something like:
142+
143+
```python
144+
proxy = Proxy.parse_url("socks5://123.123.123.123:9190")
145+
```
146+
147+
We recommend entering IP-based access control for incoming addresses to proxy. IP address required by
148+
[Anticaptcha.com](http://getcaptchasolution.com/p9bwplkicx) is:
149+
150+
```
151+
69.65.41.21
152+
209.212.146.168
153+
```
154+
155+
### Error handling
156+
157+
In the event of an application error, the `AnticaptchaException` exception is thrown. To handle the exception, do the following:
158+
159+
```python
160+
from python_anticaptcha import AnticaptchaException, ImageToTextTask
161+
162+
try:
163+
# any actions
164+
except AnticaptchaException as e:
165+
if e.error_code == 'ERROR_ZERO_BALANCE':
166+
notify_about_no_funds(e.error_id, e.error_code, e.error_description)
167+
else:
168+
raise
169+
```
170+
171+
> **Note:** The legacy misspelled `AnticatpchaException` alias is still available for backward compatibility.
172+
173+
## Versioning
174+
175+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the
176+
[tags on this repository](https://github.com/ad-m/python-anticaptcha/tags).
177+
178+
## Authors
179+
180+
- **Adam Dobrawy** - *Initial work* - [ad-m](https://github.com/ad-m)
181+
182+
See also the list of [contributors](https://github.com/ad-m/python-anticaptcha/contributors) who participated in this project.
183+
184+
## License
185+
186+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md)
187+
file for details

0 commit comments

Comments
 (0)