-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTrataCampos.py
More file actions
94 lines (74 loc) · 2.27 KB
/
TrataCampos.py
File metadata and controls
94 lines (74 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
class TrataCampos:
def __init__(self, valores):
self.valores = valores
def getUrl(self):
if self.valores[1] is None:
return ''
return self.valores[1]
def getUseragent(self):
if self.valores[2] is None:
return ''
return self.valores[2]
def getReferer(self):
if self.valores[3] is None:
return ''
if len(self.valores[3]) > 512:
return self.valores[3][0:512]
return self.valores[3]
def getLatency(self):
if self.valores[4] is None:
return 0
return self.valores[4]
def getResponse(self):
if self.valores[5] is None:
return ''
return self.valores[5]
def getId(self):
if self.valores[6] is None:
return ''
return self.valores[6]
def getSize(self):
if self.valores[7] is None:
return 0
return self.valores[7]
def getStatus(self):
if self.valores[8] is None:
return ''
return self.valores[8]
def getBloco(self,txt):
if txt is None:
return ''
if len(txt) > 80:
return txt[0:80]
return txt
@staticmethod
def extractBlocoCdn( txt ):
txt = txt.replace('https://cdn.nobeta.com.br/', '')
# vazio
if len( txt ) == 0:
return 'outros'
# identificar tag iab.min.js
if txt == 'iab.min.js':
return txt
# identificar assinaturas
x = re.search("^sign/.*/(.*)\.", txt)
if x is not None:
res = x[1].replace('sign_', '')
return 'sign-' + res
x = re.search("^sign/(.*)\.", txt)
if x is not None:
res = x[1].replace('sign_', '')
return 'sign-' + res
# idenfificar tag iab de parceiro
x = re.search("^iab-(.*)\.min\.js", txt)
if x is not None:
return x[1]
# identificar versão cdn da tag nobeta
x = re.search("^sign/(.*)\.", txt)
if x is not None:
return x[1]
# midia kit
if txt == 'midia/midiakit_2020_nobeta.pdf':
return 'midia'
# agrupar se não encaixar em nenhum item
return 'outros'