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_key = api_key,
botname = botname
)
A Simple Example
from requests import Session
from pdc_session.session_persist import SessionPersist
SessionPersist.username = 'test'
with SessionPersist() as sp:
session = Session()
sp.create(lock=True)
sp.get_session()
sp.session_id
sp.session_valid
sp.session_id = 'someid'
sp.lock_session()
sp.release_session()
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()