39 lines
920 B
Python
39 lines
920 B
Python
import re
|
|
from iwla import IWLA
|
|
|
|
# Remove logo from indefero
|
|
logo_re = re.compile(r'^.+/logo/$')
|
|
|
|
PLUGIN_CLASS = 'HTTP'
|
|
API_VERSION = 1
|
|
|
|
def get_plugins_infos():
|
|
infos = {
|
|
'class' : PLUGIN_CLASS,
|
|
'min_version' : API_VERSION,
|
|
'max_version' : -1
|
|
}
|
|
return infos
|
|
|
|
def load():
|
|
return True
|
|
|
|
# Basic rule to detect robots
|
|
|
|
def hook(iwla):
|
|
hits = iwla.getCurrentVisists()
|
|
|
|
for k in hits.keys():
|
|
super_hit = hits[k]
|
|
|
|
if super_hit['robot']: continue
|
|
|
|
for p in super_hit['requests']:
|
|
if not p['is_page']: continue
|
|
if int(p['status']) != 200: continue
|
|
if p['time_decoded'].tm_mday != super_hit['last_access'].tm_mday: continue
|
|
if logo_re.match(p['extract_request']['extract_uri']):
|
|
p['is_page'] = False
|
|
super_hit['viewed_pages'] -= 1
|
|
super_hit['viewed_hits'] += 1
|