Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
jd_data_process
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
806bac94
authored
Oct 17, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add attr
parent
108374fa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
pop_attr.json
test5.py
pop_attr.json
0 → 100644
View file @
806bac94
This diff is collapsed.
Click to expand it.
test5.py
View file @
806bac94
...
@@ -97,7 +97,6 @@ def get_pop_attr(class_id: int):
...
@@ -97,7 +97,6 @@ def get_pop_attr(class_id: int):
"field"
:
"attrValueList"
"field"
:
"attrValueList"
}
}
ans
=
request_to_jd_pop
(
method_name
,
token
,
app_key
,
app_secret
,
param
)
ans
=
request_to_jd_pop
(
method_name
,
token
,
app_key
,
app_secret
,
param
)
print
(
json
.
dumps
(
ans
,
ensure_ascii
=
False
))
return
ans
return
ans
def
insert_pop_class_to_db
():
def
insert_pop_class_to_db
():
...
@@ -137,9 +136,58 @@ def insert_pop_attr_to_db():
...
@@ -137,9 +136,58 @@ def insert_pop_attr_to_db():
result
=
cursor
.
fetchall
()
result
=
cursor
.
fetchall
()
for
i
in
range
(
len
(
result
)):
for
i
in
range
(
len
(
result
)):
class_id
=
result
[
i
][
0
]
class_id
=
result
[
i
][
0
]
ans
=
get_pop_attr
(
class_id
)
result
=
ans
[
"jingdong_category_read_findAttrsByCategoryIdUnlimitCate_responce"
][
"findattrsbycategoryidunlimitcate_result"
]
for
j
in
range
(
len
(
result
)):
input_type
=
result
[
j
][
"inputType"
]
attr_id
=
result
[
j
][
"id"
]
attr_name
=
result
[
j
][
"name"
]
enum_value
=
""
flag
=
result
[
j
][
"isRequired"
]
status
=
1
platform
=
3
create_time
=
int
(
time
.
time
())
unit
=
""
if
flag
:
is_required
=
1
else
:
is_required
=
0
if
input_type
==
1
or
input_type
==
2
:
value_list
=
result
[
j
][
"attrValueList"
]
tmp_list
=
[]
for
k
in
range
(
len
(
value_list
)):
attr_value_id
=
value_list
[
k
][
"id"
]
attr_value_name
=
value_list
[
k
][
"name"
]
item
=
{
"attr_value_id"
:
attr_value_id
,
"attr_value_name"
:
attr_value_name
}
tmp_list
.
append
(
item
)
enum_value
=
json
.
dumps
(
tmp_list
,
ensure_ascii
=
False
)
else
:
enum_value
=
"[]"
if
input_type
==
10
:
# 单独处理单位
features
=
result
[
j
][
"features"
]
for
k
in
range
(
len
(
features
)):
item
=
features
[
k
]
if
item
[
"key"
]
==
"combinationValue"
:
unit_str
=
item
[
"fvalue"
]
unit_arr
=
json
.
loads
(
unit_str
)
unit_item
=
unit_arr
[
0
]
unit_list
=
unit_item
[
"unit"
]
unit
=
json
.
dumps
(
unit_list
,
ensure_ascii
=
False
)
insert_sql
=
"insert into lie_shop_attr (class_id, attr_id, attr_name, unit, enum_value, input_type, is_required, status, platform, create_time) values (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s)"
cursor
.
execute
(
query
=
insert_sql
,
args
=
(
class_id
,
attr_id
,
attr_name
,
unit
,
enum_value
,
input_type
,
is_required
,
status
,
platform
,
create_time
,))
db
.
commit
()
print
(
insert_sql
%
(
class_id
,
attr_id
,
attr_name
,
unit
,
enum_value
,
input_type
,
is_required
,
status
,
platform
,
create_time
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
insert_pop_class_to_db
()
ans
=
get_pop_attr
(
33593
)
\ No newline at end of file
print
(
json
.
dumps
(
ans
,
ensure_ascii
=
False
))
\ No newline at end of file
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