File: README.rst

package info (click to toggle)
librecaptcha 0.6.4-1
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 200 kB
  • sloc: python: 1,453; makefile: 2
file content (211 lines) | stat: -rw-r--r-- 6,089 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
librecaptcha
============

Version 0.6.4

librecaptcha is a free/libre program and library that allows you to solve
`reCAPTCHA`_ challenges.

*librecaptcha does not automatically solve challenges and is not designed to
make it easier to do so—it provides an interface through which a human can
solve the challenges without proprietary software.*

.. _reCAPTCHA: https://en.wikipedia.org/wiki/ReCAPTCHA


Installation
------------

From PyPI
~~~~~~~~~

Install with `pip`_::

    sudo pip3 install librecaptcha[gtk]

To install locally, run without ``sudo`` and add the ``--user`` option.
You can omit ``[gtk]`` if you don’t want to install the GTK 3 GUI.


From the Git repository
~~~~~~~~~~~~~~~~~~~~~~~

Clone the repository with the following commands (you’ll need to have `Git`_
installed)::

    git clone https://github.com/taylordotfish/librecaptcha
    cd librecaptcha

Then install with `pip`_::

    sudo pip3 install .[gtk]

To install locally, run without ``sudo`` and add the ``--user`` option.
You can omit ``[gtk]`` if you don’t want to install the GTK 3 GUI.


Run without installing
~~~~~~~~~~~~~~~~~~~~~~

Run the first set of commands in the previous section to clone the repository.
Then, install the required dependencies by running::

    sudo pip3 install -r requirements.txt

To install the dependencies locally, run without ``sudo`` and add ``--user``.

.. _pip: https://pip.pypa.io
.. _Git: https://git-scm.com


Usage
-----

If you installed librecaptcha, you can simply run ``librecaptcha``.
Otherwise, run ``./librecaptcha.py``. Pass the ``--help`` option to show usage
information. If you’d like to use the GUI, be sure to pass the ``--gui``
option.

To use librecaptcha programmatically, import it::

    import librecaptcha

and then call ``librecaptcha.get_token()``. Its signature is::

    get_token(
        api_key: str,
        site_url: str,
        user_agent: str, *,
        gui=False,
        debug=False,
    ) -> str

Parameters:

* ``api_key``:
  The reCAPTCHA API key to use. This is usually the value of the
  ``data-sitekey`` HTML attribute.

* ``site_url``:
  The base URL of the site that contains the reCAPTCHA challenge. This should
  start with ``http://`` or ``https://`` and include the hostname. Everything
  after the hostname is optional. For example: ``https://example.com``

* ``user_agent``:
  The user-agent string to use. This should match the user-agent used when
  sending the request that requires a reCAPTCHA token. You can generate a
  random user-agent string with ``librecaptcha.random_user_agent()``.

* ``gui``:
  Whether to use the GTK 3 GUI (as opposed to the CLI). The CLI writes to
  standard output and reads from standard input.

* ``debug``:
  Whether to print debug information.

Returns: A reCAPTCHA token. This should usually be submitted with the form as
the value of the ``g-recaptcha-response`` field. These tokens usually expire
after a couple of minutes.


Notes
-----

librecaptcha currently supports two types of challenges: *dynamic* and
*multicaptcha*.

*dynamic* challenges present you with a grid of different images and ask you to
select the images that match the given description. Each time you click an
image, a new one takes its place. Usually, three images from the initial
set match the description, and at least one of the replacement images does as
well.

*multicaptcha* challenges present you with one large image split into a grid
of tiles and ask you to select the tiles that contain a given object.
Occasionally, the image will not contain the object, but rather something that
looks similar. It is possible to select no tiles in this case, but reCAPTCHA
may have been fooled by the similar-looking object and would reject a selection
of no tiles.


Known issues
------------

Even when all challenges are completed and a token is obtained, the token may
still be rejected when used. If this happens, simply try again. Waiting a
while, using a computer on a different network, or using a different user-agent
string may also help. Unfortunately, you may have to try many times—perhaps
dozens or more.


What’s new
----------

Version 0.6.3:

* librecaptcha should now work again, aside from the existing issues with
  tokens sometimes being rejected.

Version 0.6.0:

* Added ``librecaptcha.has_gui()``, which returns whether the GUI can be used.
* Improved cross-platform support for the CLI.

Version 0.5.0:

* Added a GTK 3 GUI (thanks, cyclopsian!).
* ``get_token()`` now has an optional ``gui`` parameter.
* ``get_token()`` now requires a user-agent string.
* ``librecaptcha.py`` now has a ``--gui`` option.
* ``librecaptcha.py`` now accepts an optional ``<user-agent>`` argument.
  If not provided, a random user-agent string is chosen and shown.

Version 0.4.0:

* Image windows are now automatically closed when questions are answered.

Version 0.3.x:

* Fixed possible encoding issue in ``setup.py``.
* librecaptcha can now be installed from PyPI, or from the Git repository with
  pip or ``setup.py``.

Version 0.2.x:

* Updated user-agent list.
* The current reCAPTCHA version is now fetched during initialization and no
  longer needs to be manually updated.


Dependencies
------------

* `Python`_ ≥ 3.5
* The following Python packages:

  - `Pillow`_
  - `requests`_
  - `slimit`_
  - `PyGObject`_ (only for GUI)

The installation instructions above handle installing the Python packages.
Alternatively, running ``pip3 install -r requirements.freeze.txt`` will install
specific versions of the dependencies that have been confirmed to work.

.. _Python: https://www.python.org/
.. _Pillow: https://pypi.org/project/Pillow/
.. _requests: https://pypi.org/project/requests/
.. _slimit: https://pypi.org/project/slimit/
.. _PyGObject: https://pypi.org/project/PyGObject/


License
-------

librecaptcha is licensed under the GNU General Public License, version 3 or
any later version. See `LICENSE`_.

This README file has been released to the public domain using `CC0`_.

.. _LICENSE: LICENSE
.. _CC0: https://creativecommons.org/publicdomain/zero/1.0/