online_test.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import os
  2. import time
  3. import requests
  4. import json
  5. import glob
  6. path = r'E:\online\txt'
  7. files = glob.glob(path+"\*.txt")
  8. count = 0
  9. for file in files:
  10. try:
  11. root, name = os.path.split(file)
  12. with open(file, encoding="utf-8") as f:
  13. count+=1
  14. print('第{}篇:{} >>>开始解析<<<'.format(count,file))
  15. con = f.readlines()
  16. data = {"file": json.dumps(con)}
  17. # print(con)
  18. # res = requests.get("http://192.168.1.152:18088/txt_parse", params=data)
  19. # res = requests.post("http://192.168.1.152:18088/txt_parse", data=data)
  20. start_time = time.time()
  21. # res = requests.post("http://192.168.1.207:18084/txt_parse", data=data)
  22. res = requests.post("http://127.0.0.1:18088/txt_parse", data=data)
  23. # res = json.loads(res.text)
  24. res = res.json()
  25. end_time = time.time()
  26. print('第 {} 篇:{} >>>完成解析<<<, 用时:{}'.format(count,file,(end_time-start_time)))
  27. except:
  28. with open(r'./error_file.txt','a') as f:
  29. f.write(name+'\n')