Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Miguel Ángel González Gallardo
/
AnalizadorLogs
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b65bb615
authored
May 06, 2021
by
Miguel Ángel González Gallardo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Filtrado corregido
parent
93a4748b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
17 deletions
codigo/Dato.py
codigo/Filtros.py
codigo/ObtencionRegistro.py
codigo/__pycache__/Dato.cpython-39.pyc
codigo/__pycache__/Filtros.cpython-39.pyc
codigo/__pycache__/ObtencionRegistro.cpython-39.pyc
codigo/Dato.py
View file @
b65bb615
...
...
@@ -41,6 +41,8 @@ class Dato:
self
.
Clave
,
c
=
sacarLinea
(
cadena
,
c
,
aux
,
' '
)
self
.
Usuario
,
c
=
sacarLinea
(
cadena
,
c
,
aux
,
' '
)
self
.
Fecha
,
c
=
leerFecha
(
cadena
,
c
,
aux
)
self
.
Offset
,
c
=
sacarLinea
(
cadena
,
c
,
aux
,
']'
)
self
.
Offset
=
self
.
Offset
[
1
:
len
(
self
.
Offset
)]
# Obtenemos modo de petición, url y protocolo
c
=
leerLinea
(
cadena
,
c
,
'"'
)
...
...
codigo/Filtros.py
View file @
b65bb615
...
...
@@ -2,6 +2,8 @@
def
getFormatosFromCSV
(
cad
):
if
cad
!=
""
and
cad
[
len
(
cad
)
-
1
]
!=
';'
:
cad
+=
';'
ret
=
cad
.
split
(
sep
=
';'
)
for
i
in
range
(
len
(
ret
)):
if
ret
[
i
]
!=
""
and
ret
[
i
][
0
]
!=
'.'
:
...
...
codigo/ObtencionRegistro.py
View file @
b65bb615
...
...
@@ -22,7 +22,8 @@ def leerLog(ruta, extensionesAdmitidas, extensionesNoAdmitidas):
try
:
aux
=
Dato
(
linea
)
if
not
aux
.
isPerdido
():
# Si no es un valor perdido lo incluimos en los registros
ret
=
obtenerDato
(
ret
,
extensionesAdmitidas
,
extensionesNoAdmitidas
,
aux
)
if
datoAdmitido
(
extensionesAdmitidas
,
extensionesNoAdmitidas
,
aux
):
ret
.
append
(
aux
)
except
:
continue
f
.
close
()
...
...
@@ -30,25 +31,51 @@ def leerLog(ruta, extensionesAdmitidas, extensionesNoAdmitidas):
return
ret
# Obtengo el dato de los registros dependiendo de qué extensiones procede
def
obtenerDato
(
ret
,
extensionesAdmitidas
,
extensionesNoAdmitidas
,
aux
):
# Compruebo si el dato pertenece a una extension NO admitida
admitir
=
True
for
ext
in
extensionesNoAdmitidas
:
if
ext
in
aux
.
URL_Solicitada
:
admitir
=
False
# Miro si el dato procede ser insertado o no
def
datoAdmitido
(
extensionesAdmitidas
,
extensionesNoAdmitidas
,
reg
):
#Por defecto, si las listas estan vacias, se acepta todo
if
len
(
extensionesAdmitidas
)
==
0
and
len
(
extensionesNoAdmitidas
)
==
0
:
return
True
ext
=
""
if
'.'
not
in
reg
.
URL_Solicitada
:
#<-- Si el registro no tiene extension
sinExtension
=
True
else
:
sinExtension
=
False
#Saco la extension
c
=
0
while
c
<
len
(
reg
.
URL_Solicitada
)
and
reg
.
URL_Solicitada
[
c
]
!=
'.'
:
c
+=
1
ext
=
reg
.
URL_Solicitada
[
c
:
len
(
reg
.
URL_Solicitada
)]
# Si no se corresponde con ninguna extension NO admitida, compruebo si hay que filtrar con las admitidas
if
admitir
:
if
len
(
extensionesAdmitidas
)
==
0
:
ret
.
append
(
aux
)
if
len
(
extensionesAdmitidas
)
!=
0
:
#Se filtra por extensiones admitidas
if
sinExtension
:
if
""
in
extensionesAdmitidas
:
return
True
else
:
return
False
else
:
# Filtro con las admitidas
for
ext
in
extensionesAdmitidas
:
if
ext
in
aux
.
URL_Solicitada
:
ret
.
append
(
aux
)
if
ext
in
extensionesAdmitidas
:
return
True
else
:
return
False
else
:
if
sinExtension
:
if
""
not
in
extensionesNoAdmitidas
:
return
True
else
:
return
False
else
:
if
ext
not
in
extensionesNoAdmitidas
:
return
True
else
:
return
False
return
ret
# Quita las entradas que pertenecen arañas, bots o crawler
...
...
codigo/__pycache__/Dato.cpython-39.pyc
View file @
b65bb615
No preview for this file type
codigo/__pycache__/Filtros.cpython-39.pyc
View file @
b65bb615
No preview for this file type
codigo/__pycache__/ObtencionRegistro.cpython-39.pyc
View file @
b65bb615
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment