test.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """
  2. @author: luojunhui
  3. """
  4. import json
  5. import time
  6. import requests
  7. import argparse
  8. from concurrent.futures import ThreadPoolExecutor
  9. def request_data(url):
  10. # index = _url.split("#")[0]
  11. # url = _url.split("#")[1]
  12. body = {
  13. "search_keys": ["日本"],
  14. "ghId": "gh_efaf7da157f5"
  15. }
  16. t = time.time()
  17. res = requests.post(url, json=body)
  18. e = time.time()
  19. # print(index)
  20. print(e - t)
  21. print(json.dumps(res.json(), ensure_ascii=False, indent=4))
  22. # print(res.json())
  23. if __name__ == "__main__":
  24. # parser = argparse.ArgumentParser() # 新建参数解释器对象
  25. # parser.add_argument("--thread")
  26. # args = parser.parse_args()
  27. # thread = int(args.thread)
  28. # dt = ["http://61.48.133.26:8111/title_to_video"]
  29. dt = ["http://127.0.0.1:5000/search_videos"]
  30. # total_s = time.time()
  31. request_data(dt[0])
  32. # with ThreadPoolExecutor(max_workers=thread) as pool:
  33. # pool.map(request_data, dt)
  34. # total_e = time.time()
  35. # print(total_e - total_s)