A wrapper on requests session with persistance and login functionalities
Project description
persession
A wrapper on requests.Session with following additional functionalities:
- Persistance: session can be cached in a file.
- Login functionalities: login and is_logged_in functions are available to help logging into sites
Usage
from persession import Session, LoginStatus
base_url = 'https://e.com'
cache_file_path = 'cache.dat'
session = Session(cache_file_path)
is_logged_in = session.is_logged_in()
if not is_logged_in:
login_url = base_url + '/login'
data = {'user': 'user', 'password': 'pass'}
res = session.login(login_url)
if res.login_status = LoginStatus.SUCCESS:
is_logged_in = True
print('Login success')
else:
print('login failed')
if is_logged_in:
data_url = base_url + '/data'
res = session.get(data_url)
You can also check out test.py for another example.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
persession-0.0.1.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for persession-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dadd2fe1bfa70dfc4c42bb19fb658ea0559dba38951a6edb793bf57ccc4f1dba |
|
MD5 | d5855dd976054c97ef69e28bd4fa65be |
|
BLAKE2b-256 | 7020689344f9032bfc2b7dc1638431705a79dc3c2e8b4e70a73e22f769cc3e89 |