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
aa4469d5
Commit
aa4469d5
authored
Jul 22, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
57d194d2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
output_results.py
crawler_sys/utils/output_results.py
+8
-7
No files found.
crawler_sys/utils/output_results.py
View file @
aa4469d5
...
...
@@ -41,7 +41,7 @@ def form_data_Lst_for_url_register(data_Lst_ori):
return
data_Lst_reg
def
hot_words_output_result
(
result_Lst
,
output_index
=
"short-video-hotwords"
,
output_doc
=
"doc"
):
def
hot_words_output_result
(
result_Lst
,
output_index
=
"short-video-hotwords"
):
bulk_all_body
=
""
for
count
,
result
in
enumerate
(
result_Lst
):
doc_id
=
result
[
"platform"
]
+
"_"
+
result
[
"title"
]
...
...
@@ -51,7 +51,7 @@ def hot_words_output_result(result_Lst,output_index="short-video-hotwords",outpu
bulk_all_body
+=
bulk_one_body
if
count
%
500
==
0
and
count
>
0
:
eror_dic
=
es_site_crawler
.
bulk
(
index
=
output_index
,
doc_type
=
output_doc
,
eror_dic
=
es_site_crawler
.
bulk
(
index
=
output_index
,
body
=
bulk_all_body
,
request_timeout
=
200
)
bulk_all_body
=
''
if
eror_dic
[
'errors'
]
is
True
:
...
...
@@ -63,7 +63,7 @@ def hot_words_output_result(result_Lst,output_index="short-video-hotwords",outpu
if
bulk_all_body
!=
''
:
eror_dic
=
es_site_crawler
.
bulk
(
body
=
bulk_all_body
,
index
=
output_index
,
doc_type
=
output_doc
,
request_timeout
=
200
)
if
eror_dic
[
'errors'
]
is
True
:
print
(
eror_dic
)
...
...
@@ -151,11 +151,12 @@ def bulk_write_into_es(dict_Lst,
bulk_write_body
=
''
write_counter
=
0
def
bulk_write_with_retry_UnicodeEncodeError
(
bulk_write_body
,
def
bulk_write_with_retry_UnicodeEncodeError
(
index
,
bulk_write_body
,
retry_counter_for_UnicodeEncodeError
):
if
bulk_write_body
!=
''
:
try
:
bulk_write_resp
=
es_site_crawler
.
bulk
(
body
=
bulk_write_body
,
bulk_write_resp
=
es_site_crawler
.
bulk
(
index
=
index
,
body
=
bulk_write_body
,
request_timeout
=
100
)
bulk_write_body
=
''
# print(bulk_write_resp)
...
...
@@ -168,7 +169,7 @@ def bulk_write_into_es(dict_Lst,
if
len
(
ill_str_idxs
)
==
2
:
ill_str
=
bulk_write_body
[
ill_str_idxs
[
0
]:
ill_str_idxs
[
1
]
+
1
]
bulk_write_body
=
bulk_write_body
.
replace
(
ill_str
,
''
)
bulk_write_with_retry_UnicodeEncodeError
(
bulk_write_body
,
bulk_write_with_retry_UnicodeEncodeError
(
index
,
bulk_write_body
,
retry_counter_for_UnicodeEncodeError
)
except
TransportError
:
...
...
@@ -196,7 +197,7 @@ def bulk_write_into_es(dict_Lst,
len
(
dict_Lst
)))
if
bulk_write_body
!=
''
:
retry_counter_for_UnicodeEncodeError
=
0
retry_counter_for_UnicodeEncodeError
=
bulk_write_with_retry_UnicodeEncodeError
(
retry_counter_for_UnicodeEncodeError
=
bulk_write_with_retry_UnicodeEncodeError
(
index
,
bulk_write_body
,
retry_counter_for_UnicodeEncodeError
)
bulk_write_body
=
''
...
...
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