1234567891011121314151617181920212223242526272829303132333435 |
- import os
- import time
- import requests
- import json
- import glob
- path = r'E:\online\txt'
- files = glob.glob(path+"\*.txt")
- count = 0
- for file in files:
- try:
- root, name = os.path.split(file)
- with open(file, encoding="utf-8") as f:
- count+=1
- print('第{}篇:{} >>>开始解析<<<'.format(count,file))
- con = f.readlines()
- data = {"file": json.dumps(con)}
- # print(con)
- # res = requests.get("http://192.168.1.152:18088/txt_parse", params=data)
- # res = requests.post("http://192.168.1.152:18088/txt_parse", data=data)
- start_time = time.time()
- # res = requests.post("http://192.168.1.207:18084/txt_parse", data=data)
- res = requests.post("http://127.0.0.1:18088/txt_parse", data=data)
- # res = json.loads(res.text)
- res = res.json()
- end_time = time.time()
- print('第 {} 篇:{} >>>完成解析<<<, 用时:{}'.format(count,file,(end_time-start_time)))
- except:
- with open(r'./error_file.txt','a') as f:
- f.write(name+'\n')
|