usr bin env python coding utf-8 import re class Counter def __init__ s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
#coding:utf-8
import re
class Counter:
def __init__(self):
self.n = 0
def inc(self):
self.n += 1
def __repr__(self):
return unicode(self.n)
set = {}
f = file('log.html', 'r')
pattern = re.compile(r' <span class="selfmoder">(.*)</span>(.*)<br />', re.U)
result = pattern.findall(f.read())
for row in result:
set.setdefault(unicode(row[0]), Counter()).inc()