展开全部
不清楚你是不62616964757a686964616fe59b9ee7ad9431333339653764是用apache 举apache log+python
#!/usr/bin/env python
from threading import Timer
import time
timer_interval=3000
def readlogs()
log = "/var/log/httpd/access"
reader = open(log, 'r')
contents = []
for line in reader.xreadlines() :
p = re.compile('.*"GET (\/seo\/t\.php\?.*) HTTP\/1\.1".*', re.IGNORECASE)
m = p.match(line)
if m :
res_file = m.group(1)
#print res_file
cs = urlparse.urlparse(res_file)
#cs_lem = len(cs)
#pprint.pprint(cs)
s_q = urlparse.parse_qs(cs.query,True)
ref = urlparse.urlparse(str(s_q['ref'][0]))
ref_wd = urlparse.parse_qs(ref.query,True)
print ref_wd['wd'][0]
else :
contents.append(line)
reader.close()
return contents
def parselog():
contents = readlogs()
for i in contents:
print i
t=Timer(timer_interval,parselog)
t.start()
while True:
time.sleep(0.1)
print 'main running'