Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
crawler
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
backend
crawler
Commits
a2dfc1e1
Commit
a2dfc1e1
authored
Aug 12, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3b8ad835
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
crawler_week_report.py
tasks/crawler_week_report.py
+14
-10
No files found.
tasks/crawler_week_report.py
View file @
a2dfc1e1
...
...
@@ -168,6 +168,8 @@ def get_es_word(word,start_ts):
class
WritrExcel
():
def
__init__
(
self
):
self
.
workbook
=
xlwt
.
Workbook
(
encoding
=
'utf-8'
)
def
set_style
(
self
,
name
,
height
,
bold
=
False
):
style
=
xlwt
.
XFStyle
()
# 初始化样式
...
...
@@ -180,11 +182,10 @@ class WritrExcel():
return
style
# 写入Excel
def
write_excel
(
self
,
path
,
rows
):
def
write_excel
(
self
,
sheet_name
,
rows
):
# 创建工作簿
workbook
=
xlwt
.
Workbook
(
encoding
=
'utf-8'
)
# 创建sheet
data_sheet
=
workbook
.
add_sheet
(
'Sheet1'
)
data_sheet
=
self
.
workbook
.
add_sheet
(
sheet_name
)
# 将样式定义在循环之外
default
=
self
.
set_style
(
'Times New Roman'
,
220
,
True
)
j
=
k
=
0
...
...
@@ -199,8 +200,11 @@ class WritrExcel():
raise
# data_sheet.write(1, i, row1[i], self.set_style('Times New Roman', 220, True))
k
=
k
+
1
workbook
.
save
(
path
)
print
(
"写入文件成功,共"
+
str
(
k
)
+
"行数据"
)
print
(
"写入sheet成功,共"
+
str
(
k
)
+
"行数据"
)
def
save_excel
(
self
,
path
):
self
.
workbook
.
save
(
path
)
def
get_search_keywrod_dict
():
...
...
@@ -307,7 +311,7 @@ def get_how_word_crawler_count(data_index, start_ts, end_ts, week_num, last_week
craw_one_week_count
=
buck
[
"doc_count"
]
push_num
=
res_dict
[
platform
][
0
]
oneline_num
=
res_dict
[
platform
][
1
]
new_line
=
(
week_num
,
platform
,
craw_one_week_count
,
push_num
,
oneline_num
)
new_line
=
(
week_num
,
platform
,
craw_one_week_count
,
push_num
,
oneline_num
,
""
)
res_data
.
append
(
new_line
)
return
res_data
...
...
@@ -350,10 +354,10 @@ if __name__ == "__main__":
print
(
craw_one_week
)
# query 一周抓取详情
all_data_week
=
craw_query_one_week
(
data_index
,
start_ts
,
end_ts
,
week_num
,
last_week_num
,
year
)
craw_one_week
.
append
(())
craw_one_week
.
append
(
all_data_week
)
path
=
"近1周数据统计结果.xls"
WritrExcel
()
.
write_excel
(
path
,
tuple
(
all_data_week
))
exl
=
WritrExcel
()
exl
.
write_excel
(
"热点内容抓取周报"
,
tuple
(
craw_one_week
))
exl
.
write_excel
(
"query抓取周报"
,
tuple
(
all_data_week
))
exl
.
save_excel
(
path
)
print
(
u'创建demo.xls文件成功'
)
send_email_tome
()
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