simple shopee session manager
Project description
Shopee Session
simple shopee session manager
Install
$ python -m pip install pdc-session
configure
from pdc_session.session_config import configure_client
api_uri = 'http://localhost:51016'
api_key = '0234a45a4d4c34f1849638f****'
botname = 'test'
configure_client(
api_uri = api_uri, # api_uri default http://localhost:4000
api_key = api_key, # api_key format string hex
botname = botname # botname format string
)
A Simple Example
from requests import Session
from pdc_session.session_persist import SessionPersist
# SessionPersist need username to run
SessionPersist.username = 'test'
with SessionPersist() as sp:
# when entering class will find available sessions and lock them
# create new session
session = Session() # session from requests
sp.create(lock=True) # lock is optional, defaults as True
# get avaliable session
# by default it is called when on enter
sp.get_session()
sp.session_id # when id is not 0, then session is valid
sp.session_valid # or check with session_valid
# if get_session() is falied, method all_locked() will be called
# lock session
# by default you need to change the session_id property and call lock_session()
sp.session_id = 'someid'
sp.lock_session() # but this is not recommended
# release session
# set session to unlocked
sp.release_session()
# update session
# by default it is called when on exit
sp.session.cookies.set('test', 'test')
sp.update_session()
Best Practice
from pdc_session.session_persist import SessionPersist
class Auth(SessionPersist):
username: str
password:str
def __init__(self, username, password):
self.username = username
self.password = password
with Auth('test', 'test') as auth:
auth.session.get('/getinfo')
auth.session.get('/product')
auth.session.post('/upload_product')
Blocking Code
from pdc_session.session_persist import SessionPersist
class Auth(SessionPersist):
username: str
password:str
def __init__(self, username, password):
self.username = username
self.password = password
user = Auth('test', 'test')
user._acquire()
auth.session.get('/getinfo')
auth.session.get('/product')
auth.session.post('/upload_product')
user._release()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pdc_session-0.1.15.tar.gz
(6.3 kB
view hashes)
Built Distribution
Close
Hashes for pdc_session-0.1.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cec0e7760bc0cf444fe3e47bdfa5454d85fc8f20b908260113e25acfba2c253e |
|
MD5 | c31fa4bcd716d647f54b302ce9f4f623 |
|
BLAKE2b-256 | ab63e603eddb1a67ac8a34f1523e871d7bf3b6f0d068912bdb6c137118754d32 |