Skip to main content

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


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.19.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

pdc_session-0.1.19-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pdc_session-0.1.19.tar.gz.

File metadata

  • Download URL: pdc_session-0.1.19.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.7 Windows/10

File hashes

Hashes for pdc_session-0.1.19.tar.gz
Algorithm Hash digest
SHA256 dd8318cc1d9da6a47d208ce79df2dd6bbb16bff72ef03b572f7b258cdac6d372
MD5 57f59fce8f8ceda7ad61aa25e7fd9c21
BLAKE2b-256 7bc8f5f1af09a0a31a34710f53225905834a470aa71b67aa3fa2541ae4e83ddd

See more details on using hashes here.

File details

Details for the file pdc_session-0.1.19-py3-none-any.whl.

File metadata

  • Download URL: pdc_session-0.1.19-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.7 Windows/10

File hashes

Hashes for pdc_session-0.1.19-py3-none-any.whl
Algorithm Hash digest
SHA256 f46aed4e578c550c1c0afa9e2340541a00017151c9e483fe6fc6e6935307fe05
MD5 4d4d79ca8cd4e514dac70b510ba05044
BLAKE2b-256 99e06317cde0dfec9c35683e4e897e37b714acbc0477e253a803a4771abb30ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page