fix pdd_api file

This commit is contained in:
why2lyj
2020-07-15 22:36:55 +08:00
parent 299911b867
commit dcdcc8ff4e
+5 -2
View File
@@ -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='')