Advertisement
rex9840

csv

May 10th, 2021
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import requests
  2. import csv
  3. import pandas as pd
  4. from typing import *
  5.  
  6. file = requests.get("http://ka-mao.xyz/log/rtime")
  7. content = file.text
  8. avg_resp_time = 0
  9. entry = 0
  10. data=dict()
  11. date=list()
  12. time=list()
  13. request=list()
  14. timeout=list()
  15. path=list()
  16. lines = content.split("\n")
  17. for line in lines:
  18.         try:
  19.             sep=line.split(' ')
  20.            
  21.             # print(sep[0])
  22.             # print(sep[1])
  23.             # print(sep[4])
  24.             # print(sep[5])
  25.             # print(sep[-2])
  26.            
  27.  
  28.             date.append(sep[0].replace(',',''))
  29.             time.append(sep[1])
  30.             request.append(sep[4])
  31.             path.append(sep[5])
  32.            
  33.            
  34.             timeout.append(float(line.split(' ')[-2].replace('ms',"")))
  35.         except IndexError:
  36.             continue
  37.        
  38.        
  39.        
  40. data=pd.DataFrame({'date':date,"time":time ,'reequest ':request ,"path ":path ,"timeout":timeout})
  41.  
  42. data.to_csv('./timeout.csv')
  43.  
  44.        
  45.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement