CASPass - Login through Central Authentification Systems
Motivation
When you write a web scraper, Central Authentification Systems are often difficult to get through. Most of them use a lot of Javascript and protection mechanisms, so it's complex to automate. Moreover, you need to understand a completely different logic, which is useless with respect to the website you want to scrap.
The chosen approach for CASPass is to avoid completely to understand the CAS
logic and to rely on a full browser, namely
Playwright, to authenticate.
This a semi-automatic process since you need to manually enter your credentials,
on the login page you are used to work with. But it's only needed one time,
CASPass save all the cookies into a file which can be used by a traditional
scrapper library (like requests or
httpx).
Obviously this semi-automatic approach is not usable in a fully non-interactive context, like a CI/CD system. However, it has many advantages:
- no need to understand the CAS,
- no need to bother with Captcha,
- no complex logic to understand,
- moreover, most of the authentication tokens stored in cookies have a pretty long duration, so you will only have to manually log in from time to time.
CASPass works also without a CAS: when the login process is full of
Javascript, Captcha or other security checks and too complex to automate, just
use this module to authenticate and then perform the scraping with a more
efficient tool.
Installation
pip install python-caspass
or
pip install git+https://codeberg.org/oschwand/python-caspass
Usage
The CASPass constructor expects two arguments:
- a list of URL leading to the login page (you may need to provide multiple links in order to satisfy the security checks)
- the success URL, reached after successful login (it indicates the login process is terminated)
from caspass import CASPass
cas = CASPass([url, url_login], url_success)
cas.login()
cas.save("cookies.txt")
See examples/ for some complete examples.
Licence
GPLv3+
Release files for python-caspass 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python_caspass-0.1.2.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_caspass-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / python_caspass-0.1.2.tar.gz
| Download URL | python_caspass-0.1.2.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e9518d2bd807f141134461528a6821be38b4e0ec503802d0e547d2d6a753ad0
|
|
BLAKE2b-256 checksum How to use checksums |
7ed3c4e1de1bdf947cef3b10f5c534dcc8ccd9d10279662535ebeffd2257ed92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.2 Linux/6.1.0-17-amd64
|
Release files / python_caspass-0.1.2-py3-none-any.whl
| Download URL | python_caspass-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3499dfd8e206638bc91a695747bc8d2ec41ff34cf923928aaf0bd065ebc3c543
|
|
BLAKE2b-256 checksum How to use checksums |
6c53bd9967ac436a8f9d28db120917b9b1500bee8f5a7f1d95f880d3ad8d754e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.2 Linux/6.1.0-17-amd64
|