From dcdcc8ff4e32ad111ee2e134555930454701996d Mon Sep 17 00:00:00 2001 From: why2lyj Date: Wed, 15 Jul 2020 22:36:55 +0800 Subject: [PATCH] fix pdd_api file --- untils/{pdd_api => pdd_api.py} | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) rename untils/{pdd_api => pdd_api.py} (93%) diff --git a/untils/pdd_api b/untils/pdd_api.py similarity index 93% rename from untils/pdd_api rename to untils/pdd_api.py index 99a8f19..dd36e5f 100644 --- a/untils/pdd_api +++ b/untils/pdd_api.py @@ -4,6 +4,7 @@ import time PDD_API_ROOT = 'https://gw-api.pinduoduo.com/api/router' + class PddApiClient(object): def __init__(self, app_key, secret_key): self.app_key = app_key @@ -11,7 +12,8 @@ class PddApiClient(object): def get_sign(self, params): params_list = sorted(list(params.items()), key=lambda x: x[0]) - params_bytes = (self.secret_key + ''.join("%s%s" % (k, v) for k, v in params_list) + self.secret_key).encode('utf-8') + params_bytes = (self.secret_key + ''.join("%s%s" % (k, v) for k, v in params_list) + self.secret_key).encode( + 'utf-8') sign = hashlib.md5(params_bytes).hexdigest().upper() return sign @@ -29,7 +31,8 @@ class PddApiClient(object): resp = requests.get(PDD_API_ROOT, params=params, **kwargs) print(resp.url) return resp - + + if __name__ == '__main__': pass # pdd = PddApiClient(app_key='', secret_key='')