Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A wrapper on requests session with persistence and login functionalities

Project description

PERSESSION (PERsistent SESSION)

A wrapper on requests.Session with following additional functionalities:

  • Persistence: session can be cached in a file for persistence between script runs.
  • 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, data)
    if res.login_status != LoginStatus.FAILURE:
        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 example.py for a detailed example.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for persession, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size persession-0.1.4-py3-none-any.whl (9.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size persession-0.1.4.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page