在生産環境中每天會有大量的使用者通路網站将會産生大量的日志檔案那麼怎麼才能知道相對于昨天今天使用者又通路了哪些新的網址下面的這個python腳本可以做到.
1.首先我們要先把昨天和今天的日志檔案的url部分提取出來并分别放入不同的檔案中
然後在運作下面的python腳本
U_F2 = input('please enter the URL file you have extracted today:')
U_F1 = input('please enter the URL file that was extracted yesterday:')
with open (U_F2) as f2:
s2 = set(f2)
with open(U_F1) as f1:
s1 = set(f1)
U_F3 = input('please enter the file name of the data you want to store:')
with open(U_F3,'w') as f3:
f3.writelines(s2-s1)
歡迎大家觀看我的視訊教程:Python入門到進階
