Wrapper for requests that saves cookie data between script runs, typically for login sessions
Project description
requestsloginsession
requestsloginsession
is a simple wrapper for requests.Session()
that saves the data locally via pickle to allow session information to be recalled on subsequent script runs without needing to relogin. All the attributes from requests
are available.
Example usage
>>> from requestsloginsession import RequestsLoginSession
>>> login_url = "http://httpbingo.org/basic-auth/user123/passwd123"
>>> login_data = {'username' : 'user123', 'password' : 'passwd123' }
>>> mysession = RequestsLoginSession(login_url, login_data)
>>> r = mysession.retrieve_content("http://httpbingo.org/cookies/set?k1=v1234&k2=v5678")
>>>
$ file httpbingo.org_session.dat
httpbingo.org_session.dat: data
$ python3
>>> from requestsloginsession.requestsloginsession import RequestsLoginSession
>>> login_url = "http://httpbingo.org/basic-auth/user123/passwd123"
>>> login_data = {'username' : 'user123', 'password' : 'passwd123' }
>>> mysession = RequestsLoginSession(login_url, login_data)
>>> r = mysession.retrieve_content("http://httpbingo.org/cookies")
>>> r.json()
{'k1': 'v1234', 'k2': 'v5678'}
>>> r.status_code
200
>>> r.text
'{\n "k1": "v1234",\n "k2": "v5678"\n}\n'
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
requestsloginsession-0.6.0.tar.gz
(16.5 kB
view hashes)
Built Distribution
Close
Hashes for requestsloginsession-0.6.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dadde080e58d663a9c18a9e98ee546a277a92e45a7576c36b183ffc165d10f1 |
|
MD5 | 4dc13c98db6c867b730ba4516c4fd508 |
|
BLAKE2b-256 | 79b954ed3c0385c1ceb3745ed182bdc236f0e65d508ffcb47eb073be118c33ce |
Close
Hashes for requestsloginsession-0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17c35a98eac72d500b8a73bb1e53db3d11cc4c22e0109b53919c166929278e1c |
|
MD5 | 518844de3316f5fbaa739022f6631c25 |
|
BLAKE2b-256 | 64566f1c8b5b0e5506a7205a232a9dd251f339df62e6db9737faa64716ba7a8d |