helper.py 699 B

1234567891011121314151617181920212223
  1. import hashlib
  2. import json
  3. import requests
  4. from requests_futures.sessions import FuturesSession
  5. class Helper(object):
  6. @staticmethod
  7. def async_post(url, params):
  8. try:
  9. fs_session = FuturesSession()
  10. data = fs_session.post(url, data={"data": json.dumps(params), "token": "02S0wW15643928255d3ebd790ce04"}, timeout=30).result()
  11. if data:
  12. return data.content.decode('utf-8')
  13. except requests.exceptions.RequestException as e:
  14. print(e)
  15. @staticmethod
  16. def genearte_MD5(params):
  17. # 创建md5对象
  18. hl = hashlib.md5()
  19. hl.update(params.encode(encoding='utf-8'))
  20. return hl.hexdigest()