凌的博客

您现在的位置是: 首页 > 学无止境 > python > 

python

网站日志 导出ua

2020-03-12 python 728
# 网站日志 导出ua
import re
with open("域名.com.log","r",encoding="utf-8") as f:
    uas = []
    for line in f.read().split("\n"):

        m = re.search("Android\s+\d|iPhone;",line)
        if m is not None:
            ua_txt = line.split('" "')
            uas.append(ua_txt[-1][:-1])
            #print(ua_txt[-1][:-1])
    uas_set = set(uas)
    with open("ua_lst.txt","w",encoding="utf-8") as fw:
        fw.write("\n".join(uas_set))


文章评论

0条评论