【发布时间】:2014-01-24 19:30:28
【问题描述】:
这是我的日志文件中“有效”行的示例:
194.81.31.125 - - [129/Dec/2013:22:03:09 -0500] "GET http://www.firemaiden.hu/cgi-bin/top/topsites.cgi?an12 HTTP/1.0" 200 558 "http://Afrique" "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"
我有这个 re.findall 表达式:(GET|POST)\s(http://|https//)[a-zA-Z]+.+?"\s200
此表达式包含有效行的所有规则,但不提取域。
我想计算每个日期的顶级域,在本例中为“hu”,并将每个域的计数转储到一个有组织的日志文件中。我还想将无效行提取到不同的日志文件中
理想的输出是:
12/Dec/2013[tab]as:1[tab]ab:2[tab]hu:4
13/Dec/2013[tab]as:4[tab]br:7[tab]cd:8
【问题讨论】:
标签: python regex apache findall logfile