Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
search_custom_analyse
Overview
Overview
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
田川
search_custom_analyse
Commits
997e6ca2
Commit
997e6ca2
authored
Dec 09, 2020
by
zhaoyanchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改目录
parent
154f1c70
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
111 additions
and
2 deletions
+111
-2
file_filter.py
src/file_filter.py
+0
-0
get_user_brand_favor_linux.py
src/get_user_brand_favor_linux.py
+109
-0
get_user_brand_favor_windows.py
src/get_user_brand_favor_windows.py
+2
-2
log_parser.py
src/log_parser.py
+0
-0
no_data_log_parser.py
src/no_data_log_parser.py
+0
-0
no_hit_analyze.py
src/no_hit_analyze.py
+0
-0
test_pandas.py
src/test_pandas.py
+0
-0
No files found.
file_filter.py
→
src/
file_filter.py
View file @
997e6ca2
File moved
src/get_user_brand_favor_linux.py
0 → 100644
View file @
997e6ca2
# - coding: utf-8 -
import
requests
import
codecs
import
sys
reload
(
sys
)
sys
.
setdefaultencoding
(
'utf-8'
)
file_path
=
r'cateword_but_no_hit.txt'
user_profile_file
=
r'user_brand_favor.txt'
brand_cache
=
{}
user_brand_favor_str_cache
=
{}
class
FavorBrands
:
def
__init__
(
self
):
self
.
top5_brand_ids
=
''
self
.
top5_brand_names
=
''
self
.
other_brand_ids
=
''
self
.
other_brand_names
=
''
def
trans_brand_id_2_name
(
brand_id
):
if
brand_id
in
brand_cache
:
return
brand_cache
[
brand_id
]
solr_brand_query_url
=
'http://solr3.secoo-inc.com:15000/solr/search_product/select?wt=json&fl=brandCName&rows=1&q=brandId:'
try
:
res
=
requests
.
get
(
solr_brand_query_url
+
str
(
brand_id
))
result
=
res
.
json
()
return
result
.
get
(
'response'
)[
'docs'
][
0
][
'brandCName'
]
except
Exception
as
err
:
print
(
err
)
def
get_favor_brands_str_from_api
(
device_id
):
res
=
requests
.
get
(
'http://rcmdprofile.secoolocal.com/soprofile?orginFeild=brand_favor&deviceId='
+
device_id
)
result
=
res
.
json
()
brand_favor
=
result
.
get
(
'brand_favor'
)
return
brand_favor
def
get_favor_brands_str_from_cache
(
device_id
):
if
device_id
in
user_brand_favor_str_cache
:
return
user_brand_favor_str_cache
[
device_id
]
return
''
def
get_favor_brands
(
device_id
):
favor_brands
=
FavorBrands
()
try
:
# brand_favor = get_favor_brands_str_from_api(device_id)
brand_favor
=
get_favor_brands_str_from_cache
(
device_id
)
brand_arr
=
brand_favor
.
split
(
'
%
'
)
brand_favor_len
=
len
(
brand_arr
)
min_len
=
brand_favor_len
if
brand_favor_len
<
5
else
5
for
i
in
range
(
min_len
):
brand_tup
=
brand_arr
[
i
]
brand_id
=
brand_tup
.
split
(
','
)[
0
]
favor_brands
.
top5_brand_ids
+=
str
(
brand_id
)
+
", "
favor_brands
.
top5_brand_names
+=
trans_brand_id_2_name
(
brand_id
)
+
", "
if
brand_favor_len
<=
5
:
return
favor_brands
for
brand_tup
in
brand_arr
[
5
:]:
brand_id
=
brand_tup
.
split
(
','
)[
0
]
favor_brands
.
other_brand_ids
+=
str
(
brand_id
)
+
", "
favor_brands
.
other_brand_names
+=
trans_brand_id_2_name
(
brand_id
)
+
", "
except
Exception
as
err
:
print
(
err
)
return
favor_brands
def
init_user_brand_favor_str_cahce
():
with
open
(
user_profile_file
,
'r'
)
as
f
:
for
line
in
f
:
str_arr
=
line
.
split
(
'
\t
'
)
if
len
(
str_arr
)
!=
2
:
continue
device_id
=
str_arr
[
0
]
brand_favor
=
str_arr
[
1
]
.
strip
()
user_brand_favor_str_cache
[
device_id
]
=
brand_favor
def
get_user_brand_cache_detail
():
with
codecs
.
open
(
file_path
,
'r'
,
'utf-8'
)
as
f
:
for
line
in
f
:
str_arr
=
line
.
split
(
'
\t
'
)
if
len
(
str_arr
)
!=
2
:
continue
device_id
=
str_arr
[
0
]
search_word
=
str_arr
[
1
]
.
strip
()
favor_brands
=
get_favor_brands
(
device_id
)
print
(
device_id
+
'
\t
'
+
search_word
+
'
\t
'
+
favor_brands
.
top5_brand_ids
+
'
\t
'
+
favor_brands
.
top5_brand_names
+
'
\t
'
+
favor_brands
.
other_brand_ids
+
'
\t
'
+
favor_brands
.
other_brand_names
)
def
main
():
init_user_brand_favor_str_cahce
()
get_user_brand_cache_detail
()
if
__name__
==
"__main__"
:
main
()
get_user_brand_favor
.py
→
src/get_user_brand_favor_windows
.py
View file @
997e6ca2
...
...
@@ -26,7 +26,7 @@ def trans_brand_id_2_name(brand_id):
try
:
res
=
requests
.
get
(
solr_brand_query_url
+
str
(
brand_id
))
result
=
res
.
json
()
print
(
type
(
result
.
get
(
'response'
)[
'docs'
][
0
][
'brandCName'
]))
return
result
.
get
(
'response'
)[
'docs'
][
0
][
'brandCName'
]
except
Exception
as
err
:
print
(
err
)
...
...
@@ -78,7 +78,7 @@ def init_user_brand_favor_str_cahce():
continue
device_id
=
str_arr
[
0
]
brand_favor
=
str_arr
[
1
]
brand_favor
=
str_arr
[
1
]
.
strip
()
user_brand_favor_str_cache
[
device_id
]
=
brand_favor
...
...
log_parser.py
→
src/
log_parser.py
View file @
997e6ca2
File moved
no_data_log_parser.py
→
src/
no_data_log_parser.py
View file @
997e6ca2
File moved
no_hit_analyze.py
→
src/
no_hit_analyze.py
View file @
997e6ca2
File moved
test_pandas.py
→
src/
test_pandas.py
View file @
997e6ca2
File moved
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