| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import hashlib
- import json
- # import requests
- from requests_futures.sessions import FuturesSession
- class Helper(object):
- @staticmethod
- def async_post(url, params):
- # try:
- # fs_session = FuturesSession()
- # data = fs_session.post(url, data={"data": json.dumps(params), "token": "u4Gdf015662654065d5b503ea2517"}, timeout=180).result()
- # if data:
- # return data.content.decode('utf-8')
- # except requests.exceptions.RequestException as e:
- # print(e)
- fs_session = FuturesSession()
- data = fs_session.post(url, data={"data": json.dumps(params), "token": "u4Gdf015662654065d5b503ea2517"}, timeout=180).result()
- try:
- new_data = data.json()
- except Exception as e:
- print(e)
- new_data = {"status": 0, "msg": "接口返回异常", "data": []}
- return new_data
- @staticmethod
- def genearte_MD5(params, pt):
- # 创建md5对象
- hl = hashlib.md5()
- pn = int(pt)
- if pn == 3:
- param = params + str(pt)
- else:
- param = params
- hl.update(param.encode(encoding='utf-8'))
- return hl.hexdigest()
- @staticmethod
- def genearte_uuid(params):
- hl = hashlib.md5()
- hl.update(params.encode(encoding='utf-8'))
- return hl.hexdigest()
|