HttpRequestsUtil.py 510 B

1234567891011121314151617181920212223
  1. # coding=utf-8
  2. import requests
  3. import json
  4. class HttpRequestsUtil(object):
  5. #post方法获取数据 application/json
  6. @staticmethod
  7. def post(url, postData,headers): #
  8. data = json.dumps(postData)
  9. response = requests.request("POST",url, data=data.encode('utf-8'),
  10. headers=headers)
  11. res = response.json()
  12. return res
  13. # if __name__ == '__main__':
  14. # httputil = HttpRequestsUtil()
  15. # httputil.postText()
  16. # HttpUtil.postText()