正文
requestUri
)
def
GetCdnLogList
(
self
):
ret
=
requests
.
get
(
self
.
url
,
params
=
self
.
params
)
return
ret
.
json
()
class
GZipTool
(
object
):
"""
压缩与解压gzip
"""
def
__init__
(
self
,
bufSize
=
1024
*
8
):
self
.
bufSize
=
bufSize
self
.
fin
=
None
self
.
fout
=
None
def
compress
(
self
,
src
,
dst
):
self
.
fin
=
open
(
src
,
'rb'
)
self
.
fout
=
gzip
.
open
(
dst
,
'wb'
)
self
.
__in2out
()
def
decompress
(
self
,
gzFile
,
dst
):
self
.
fin
=
gzip
.
open
(
gzFile
,
'rb'
)
self
.
fout
=
open
(
dst
,
'wb'
)
self
.
__in2out
()
def
__in2out
(
self
,):
while
True
:
buf
=
self
.
fin
.
read
(
self
.
bufSize
)
if
len
(
buf
)
<
1
:
break
self
.
fout
.
write
(
buf
)
self
.
fin
.
close
()
self
.
fout
.
close
()
def
download
(
link
,
name
):
try
:
r
=
requests
.
get
(
link
)
with
open
(
name
,
'wb'
)
as
f
:
f
.
write
(
r
.
content
)
return
True
except
:
return
False
def
writelog
(
src
,
dst
):
# 保存为以天命名日志
dst
=
dst
.
split
(
'-'
)[
0
][:-
2
]
+
'-'
+
dst
.
split
(
'-'
)[
1
]
with
open
(
src
,
'r'
)
as
f1
:
with
open
(
dst
,
'a+'
)
as
f2
:
for
line
in
f1
:
f2
.
write
(
line
)
if
__name__
==
'__main__'
:
#startDate = "2017-02-23 12:00:00"
#endDate = "2017-02-23 12:00:00"