iwla/plugins/pre_analysis/H002_soutade.py

39 lines
920 B
Python
Raw Normal View History

2014-11-19 08:01:12 +01:00
import re
2014-11-21 16:56:58 +01:00
from iwla import IWLA
2014-11-19 08:01:12 +01:00
# Remove logo from indefero
logo_re = re.compile(r'^.+/logo/$')
2014-11-20 16:15:57 +01:00
PLUGIN_CLASS = 'HTTP'
API_VERSION = 1
def get_plugins_infos():
2014-11-21 10:41:29 +01:00
infos = {
'class' : PLUGIN_CLASS,
'min_version' : API_VERSION,
'max_version' : -1
}
2014-11-20 16:15:57 +01:00
return infos
def load():
return True
2014-11-19 08:01:12 +01:00
# Basic rule to detect robots
2014-11-21 16:56:58 +01:00
def hook(iwla):
hits = iwla.getCurrentVisists()
2014-11-19 08:01:12 +01:00
for k in hits.keys():
super_hit = hits[k]
if super_hit['robot']: continue
2014-11-21 10:41:29 +01:00
for p in super_hit['requests']:
2014-11-19 08:01:12 +01:00
if not p['is_page']: continue
2014-11-20 16:15:57 +01:00
if int(p['status']) != 200: continue
2014-11-21 10:41:29 +01:00
if p['time_decoded'].tm_mday != super_hit['last_access'].tm_mday: continue
2014-11-19 08:01:12 +01:00
if logo_re.match(p['extract_request']['extract_uri']):
p['is_page'] = False
super_hit['viewed_pages'] -= 1
super_hit['viewed_hits'] += 1