12345678910111213141516171819202122232425262728293031323334353637 |
- import time
- import os
- def time_watcher():
- print('--- %s seconds ---' % (time.time() - start_time))
- def write_log(line, nameFile): # запись корректного лога
- path_f = os.path.dirname(os.path.abspath(__file__))
- with open(os.path.join(path_f, nameFile), "a") as log_file:
- log_file.write(line)
- def read_log():
- path_f = os.path.dirname(os.path.abspath(__file__))
- with open(os.path.join(path_f, "test.log")) as log_file:
- lines = [line.rstrip() for line in log_file]
- for i in range(len(lines)):
- try:
- string = lines[i].split('/" "')
- # print(string[1])
- write_log(string[1]+"\n", "user-agents.log")
- except:
- write_log(lines[i]+"\n", "wrong.log")
- def main():
- read_log()
- if __name__ == '__main__':
- start_time = time.time()
- main()
- time_watcher()
|