Skip to content

Commit 85ae73f

Browse files
ad-mAdam Dobrawyclaude
authored
Fix obsolete and invalid documentation (#128)
* Fix obsolete and invalid documentation across the project Update outdated references (setup.py → pyproject.toml, TravisCI → GitHub Actions), fix broken example file links, correct typos and grammar in README and Sphinx docs, update copyright year range, fix geckodriver/chromedriver naming confusion in Makefile, update contact email in CODE_OF_CONDUCT.md, and add comprehensive changelog entries for all changes since 1.0.0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Update release docs for trusted publishing via GitHub Actions Remove manual twine upload step from development docs and add trusted publishing changelog entry (PR #114). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add documentation for context manager, on_check callback, and ImageToTextTask inputs Document three recently added features that were missing usage examples: - Context manager support on AnticaptchaClient - on_check callback parameter on Job.join() - ImageToTextTask accepting file paths and raw bytes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Adam Dobrawy <naczelnik@jawne.info.pl> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0b8381e commit 85ae73f

8 files changed

Lines changed: 130 additions & 40 deletions

File tree

CHANGELOG.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,44 @@
11
Changelog
22
=========
33

4+
Unreleased
5+
----------
6+
7+
Added
8+
#####
9+
10+
- Add context manager support to ``AnticaptchaClient`` (``__enter__``, ``__exit__``, ``close``)
11+
- Add ``ANTICAPTCHA_API_KEY`` environment variable fallback for ``AnticaptchaClient``
12+
- Add ``Proxy`` frozen dataclass with ``parse_url()`` and ``to_kwargs()`` methods
13+
- Add snake_case aliases: ``create_task``, ``create_task_smee``, ``get_balance``, ``get_app_stats``
14+
- Add ``py.typed`` marker and complete type annotations (`#124 <https://github.com/ad-m/python-anticaptcha/pull/124>`_)
15+
- Add ``__repr__`` to ``Job``, ``AnticaptchaClient``, and ``BaseTask`` (`#123 <https://github.com/ad-m/python-anticaptcha/pull/123>`_)
16+
- Add optional ``on_check`` callback to ``Job.join()`` (`#125 <https://github.com/ad-m/python-anticaptcha/pull/125>`_)
17+
- ``ImageToTextTask`` now accepts file paths (``str``/``Path``), raw bytes, or file-like objects
18+
19+
Changed
20+
#######
21+
22+
- **Breaking:** Minimum Python version increased from 2.7+ to 3.9+
23+
- Migrate from ``setup.py`` / ``setup.cfg`` to ``pyproject.toml`` (PEP 621) (`#122 <https://github.com/ad-m/python-anticaptcha/pull/122>`_)
24+
- Switch README from RST to Markdown (`#126 <https://github.com/ad-m/python-anticaptcha/pull/126>`_)
25+
- Switch test runner from nose2 to pytest
26+
- Switch PyPI publishing to trusted publishing via GitHub Actions (`#114 <https://github.com/ad-m/python-anticaptcha/pull/114>`_)
27+
- Fix ``RecaptchaV2EnterpriseTask`` missing proxyless base class inheritance
28+
- Fix ``ImageToTextTask.serialize()`` sending ``None`` values
29+
- Fix ``GeeTestTask`` incorrect inheritance
30+
- Fix ``AntiGateTaskProxyless`` super() call
31+
- Remove redundant cookies serialization in ``ProxyMixin``
32+
- Use Python 3 ``super()`` without arguments throughout codebase
33+
34+
Removed
35+
#######
36+
37+
- Drop Python 2.7 and Python 3.4-3.8 support
38+
- Remove ``six`` dependency (replaced with stdlib ``urllib.parse``)
39+
- Remove ``compat.py`` module
40+
- Remove legacy ``setup.py`` and ``setup.cfg``
41+
442
1.0.0 - 2022-03-28
543
------------------
644

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe
3434

3535
## Enforcement
3636

37-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at naczelnik@jawnosc.tk. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at naczelnik@jawne.info.pl. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
3838

3939
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
4040

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
CHROMEDRIVER_VERSION=99.0.4844.17
2-
CHROMEDRIVER_DIR=${PWD}/geckodriver
2+
CHROMEDRIVER_DIR=${PWD}/chromedriver
33

4-
.PHONY: lint fmt build docs install test test_e2e gecko
4+
.PHONY: lint fmt build docs install test test_e2e chromedriver
55

66
build:
7-
python setup.py sdist bdist_wheel
7+
python -m build
88

99
install: install_test install_docs install_pkg
1010

@@ -18,7 +18,7 @@ install_pkg:
1818
python -m pip install --upgrade pip wheel
1919
pip install .
2020

21-
gecko:
21+
chromedriver:
2222
mkdir -p ${CHROMEDRIVER_DIR}
2323
wget -q -P ${CHROMEDRIVER_DIR} "http://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
2424
unzip ${CHROMEDRIVER_DIR}/chromedriver* -d ${CHROMEDRIVER_DIR}
@@ -28,10 +28,10 @@ test:
2828
pytest
2929

3030
test_e2e:
31-
PATH=$$PWD/geckodriver:$$PATH pytest -m e2e --override-ini="addopts="
31+
PATH=$$PWD/chromedriver:$$PATH pytest -m e2e --override-ini="addopts="
3232

3333
clean:
34-
rm -r build geckodriver
34+
rm -r build chromedriver
3535

3636
lint:
3737
docker run --rm -v /$$(pwd):/apps alpine/flake8 ./

README.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
[![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)
44
[![PyPI](https://img.shields.io/pypi/v/python-anticaptcha.svg)](https://pypi.org/project/python-anticaptcha/)
55
[![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)
6+
[![Python compatibility](https://img.shields.io/pypi/pyversions/python-anticaptcha.svg)](https://github.com/ad-m/python-anticaptcha/blob/master/pyproject.toml)
77

8-
Client library for solve captchas with [Anticaptcha.com support](http://getcaptchasolution.com/i1hvnzdymd).
8+
Client library for solving captchas with [Anticaptcha.com support](http://getcaptchasolution.com/i1hvnzdymd).
99
The library requires Python >= 3.9.
1010

1111
The library is cyclically and automatically tested for proper operation. We are constantly making the best efforts for its effective operation.
@@ -22,7 +22,7 @@ pip install python-anticaptcha
2222

2323
## Usage
2424

25-
To use this library do you need [Anticaptcha.com](http://getcaptchasolution.com/p9bwplkicx) API key.
25+
To use this library you need [Anticaptcha.com](http://getcaptchasolution.com/p9bwplkicx) API key.
2626

2727
You can pass the key explicitly or set the `ANTICAPTCHA_API_KEY` environment variable:
2828

@@ -34,6 +34,14 @@ client = AnticaptchaClient("my-api-key")
3434
client = AnticaptchaClient()
3535
```
3636

37+
The client can be used as a context manager to ensure the underlying session is closed:
38+
39+
```python
40+
with AnticaptchaClient(api_key) as client:
41+
job = client.create_task(task)
42+
job.join()
43+
```
44+
3745
### Solve recaptcha
3846

3947
Example snippet for Recaptcha:
@@ -52,12 +60,11 @@ job.join()
5260
print(job.get_solution_response())
5361
```
5462

55-
The full integration example is available in file `examples/recaptcha.py`.
63+
The full integration example is available in file `examples/recaptcha_request.py`.
5664

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
65+
If you process the same page many times, to increase reliability you can specify
66+
whether the captcha is visible or not. This parameter is not required, as the
67+
system detects invisible sitekeys automatically. To provide that, pass
6168
`is_invisible` parameter to `NoCaptchaTaskProxylessTask` or `NoCaptchaTask` eg.:
6269

6370
```python
@@ -82,9 +89,17 @@ Example snippet for text captcha:
8289
from python_anticaptcha import AnticaptchaClient, ImageToTextTask
8390

8491
api_key = '174faff8fbc769e94a5862391ecfd010'
85-
captcha_fp = open('examples/captcha_ms.jpeg', 'rb')
8692
client = AnticaptchaClient(api_key)
87-
task = ImageToTextTask(captcha_fp)
93+
94+
# From a file path:
95+
task = ImageToTextTask('examples/captcha_ms.jpeg')
96+
97+
# Or from raw bytes:
98+
# task = ImageToTextTask(open('examples/captcha_ms.jpeg', 'rb').read())
99+
100+
# Or from a file object:
101+
# task = ImageToTextTask(open('examples/captcha_ms.jpeg', 'rb'))
102+
88103
job = client.create_task(task)
89104
job.join()
90105
print(job.get_captcha_text())
@@ -111,6 +126,18 @@ job.join()
111126
print(job.get_token_response())
112127
```
113128

129+
### Monitor solve progress
130+
131+
You can pass an `on_check` callback to `job.join()` to monitor progress:
132+
133+
```python
134+
def progress(elapsed, status):
135+
print(f"Elapsed: {elapsed}s, status: {status}")
136+
137+
job = client.create_task(task)
138+
job.join(on_check=progress)
139+
```
140+
114141
### Report incorrect image
115142

116143
Example snippet for reporting an incorrect image task:
@@ -138,7 +165,7 @@ pip install mitmproxy
138165
mitmweb -p 9190 -b 0.0.0.0 --ignore '.' --socks
139166
```
140167

141-
Next to in your application use something like:
168+
Then in your application use something like:
142169

143170
```python
144171
proxy = Proxy.parse_url("socks5://123.123.123.123:9190")

docs/conf.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# This file does only contain a selection of the most common options. For a
66
# full list see the documentation:
7-
# http://www.sphinx-doc.org/en/stable/config
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
88

99
# -- Path setup --------------------------------------------------------------
1010

@@ -21,13 +21,12 @@
2121
# -- Project information -----------------------------------------------------
2222

2323
project = u"python-anticaptcha"
24-
copyright = u"2018, Adam Dobrawy"
24+
copyright = u"2018-2026, Adam Dobrawy"
2525
author = u"Adam Dobrawy"
2626

27-
# The short X.Y version
27+
# Version is managed by setuptools-scm; leave empty for Sphinx
2828
version = u""
29-
# The full version, including alpha/beta/rc tags
30-
release = u"0.2.0"
29+
release = u""
3130

3231

3332
# -- General configuration ---------------------------------------------------
@@ -84,10 +83,9 @@
8483
html_theme = "alabaster"
8584

8685
try:
87-
import sphinx_rtd_theme
86+
import sphinx_rtd_theme # noqa: F401
8887

8988
html_theme = "sphinx_rtd_theme"
90-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
9189
except ImportError:
9290
pass
9391

docs/development.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ The project is open-source.
55

66
Changes are managed through GitHub. Pull requests are particularly welcome.
77

8-
All changes are automatically tested using TravisCI.
8+
All changes are automatically tested using GitHub Actions.
99

1010
New release
1111
-----------
1212

1313
Follow these steps to publish the new release:
1414

1515
* update changelog - use any text editor
16-
* bump version - use ```bumpversion {major,minor,patch}```
17-
* build package - use ```python setup.py sdist bdist_wheel --universal```
18-
* upload release to PyPI - use ```twine upload dist/*```
19-
* push changes to GitHub - ```git push origin && git push --tags```
16+
* tag version - use ``git tag vX.Y.Z`` (versions are managed by ``setuptools-scm``)
17+
* push changes to GitHub - ``git push origin && git push --tags``
18+
* PyPI upload is handled automatically via GitHub Actions using `trusted publishing <https://docs.pypi.org/trusted-publishers/>`_

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Welcome to python-anticaptcha's documentation!
77
==============================================
88

9-
Client library for solve captchas with `Anticaptcha.com support`_.
9+
Client library for solving captchas with `Anticaptcha.com support`_.
1010
The library requires Python >= 3.9.
1111

1212
The library is cyclically and automatically tested for proper operation. We are constantly making the best efforts for its effective operation.

docs/usage.rst

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Usage
22
=====
33

4-
To use this library do you need `Anticaptcha.com`_ API key.
4+
To use this library you need `Anticaptcha.com`_ API key.
55

66
You can pass the key explicitly or set the ``ANTICAPTCHA_API_KEY`` environment variable:
77

@@ -13,6 +13,14 @@ You can pass the key explicitly or set the ``ANTICAPTCHA_API_KEY`` environment v
1313
# Or set ANTICAPTCHA_API_KEY environment variable
1414
client = AnticaptchaClient()
1515
16+
The client can be used as a context manager to ensure the underlying session is closed:
17+
18+
.. code:: python
19+
20+
with AnticaptchaClient(api_key) as client:
21+
job = client.create_task(task)
22+
job.join()
23+
1624
Solve recaptcha
1725
###############
1826

@@ -32,12 +40,11 @@ Example snippet for Recaptcha:
3240
job.join()
3341
print(job.get_solution_response())
3442
35-
The full integration example is available in file ``examples/recaptcha.py``.
43+
The full integration example is available in file ``examples/recaptcha_request.py``.
3644

37-
If you only process few page many times to increase reliability, you can specify
38-
whether the captcha is visible or not. This parameter is not required, as is the
39-
system detects invisible sitekeys automatically, and needs several recursive
40-
measures for automated training and analysis. For provide that pass
45+
If you process the same page many times, to increase reliability you can specify
46+
whether the captcha is visible or not. This parameter is not required, as the
47+
system detects invisible sitekeys automatically. To provide that, pass
4148
``is_invisible`` parameter to ``NoCaptchaTaskProxylessTask`` or ``NoCaptchaTask`` eg.:
4249

4350
.. code:: python
@@ -65,9 +72,17 @@ Example snippet for text captcha:
6572
from python_anticaptcha import AnticaptchaClient, ImageToTextTask
6673
6774
api_key = '174faff8fbc769e94a5862391ecfd010'
68-
captcha_fp = open('examples/captcha_ms.jpeg', 'rb')
6975
client = AnticaptchaClient(api_key)
70-
task = ImageToTextTask(captcha_fp)
76+
77+
# From a file path:
78+
task = ImageToTextTask('examples/captcha_ms.jpeg')
79+
80+
# Or from raw bytes:
81+
# task = ImageToTextTask(open('examples/captcha_ms.jpeg', 'rb').read())
82+
83+
# Or from a file object:
84+
# task = ImageToTextTask(open('examples/captcha_ms.jpeg', 'rb'))
85+
7186
job = client.create_task(task)
7287
job.join()
7388
print(job.get_captcha_text())
@@ -94,6 +109,19 @@ Example snippet for funcaptcha:
94109
job.join()
95110
print(job.get_token_response())
96111
112+
Monitor solve progress
113+
######################
114+
115+
You can pass an ``on_check`` callback to ``job.join()`` to monitor progress:
116+
117+
.. code:: python
118+
119+
def progress(elapsed, status):
120+
print(f"Elapsed: {elapsed}s, status: {status}")
121+
122+
job = client.create_task(task)
123+
job.join(on_check=progress)
124+
97125
Report incorrect image
98126
######################
99127

@@ -123,7 +151,7 @@ the possibility of simply launching such a server by:
123151
pip install mitmproxy
124152
mitmweb -p 9190 -b 0.0.0.0 --ignore '.' --socks
125153
126-
Next to in your application use something like:
154+
Then in your application use something like:
127155

128156
.. code:: python
129157

0 commit comments

Comments
 (0)