test_req.py 629 B

123456789101112131415161718192021222324252627282930
  1. """
  2. @author: luojunhui
  3. """
  4. import json
  5. import time
  6. import requests
  7. """
  8. cate: video_return, video_view, video_rov
  9. """
  10. url = "http://47.99.132.47:8888/videos"
  11. body = {
  12. "cate": "video_rov",
  13. "start_date": "2024-05-28",
  14. "end_date": "2024-05-29",
  15. "topN": 10
  16. }
  17. a = time.time()
  18. header = {
  19. "Content-Type": "application/json",
  20. }
  21. response = requests.post(url, json=body, headers=header, timeout=600)
  22. b = time.time()
  23. print(b - a)
  24. print(json.dumps(response.json(), ensure_ascii=False, indent=4))
  25. with open("test.json", "w", encoding="utf-8") as f:
  26. f.write(json.dumps(response.json(), ensure_ascii=False, indent=4))