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
dfa8eb46
authored
Oct 17, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add pop class
parent
146e68a8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
5 deletions
common.py
test5.py
common.py
View file @
dfa8eb46
...
...
@@ -33,8 +33,11 @@ def get_sign_data(method_name, token, app_key, app_secret, param) -> dict:
return
data
def
request_to_jd_pop
():
pass
def
request_to_jd_pop
(
method_name
,
token
,
app_key
,
app_secret
,
param
:
dict
):
jd_url
=
"https://api.jd.com/routerjson"
params
=
get_sign_data
(
method_name
,
token
,
app_key
,
app_secret
,
param
)
ans
=
requests
.
get
(
url
=
jd_url
,
params
=
params
)
return
ans
.
json
()
def
request_to_jd_vc
(
method_name
,
token
,
app_key
,
app_secret
,
param
:
dict
)
->
dict
:
...
...
test5.py
View file @
dfa8eb46
# 设置履约时效
import
json
import
time
import
pymysql
from
common
import
request_to_jd_vc
from
common
import
request_to_jd_pop
config_dev
=
{
"mysql"
:
{
"host"
:
"192.168.1.238"
,
"port"
:
3306
,
"user"
:
"liexin_data_distribution"
,
"password"
:
"liexin_data_distribution#zsyM"
,
"database"
:
"liexin_data_distribution"
},
"redis"
:
{
"host"
:
"192.168.1.235"
,
"port"
:
6379
,
"password"
:
"icDb29mLy2s"
}
}
config_prod
=
{
"mysql"
:
{
"host"
:
"bigdata2.ichunt.db"
,
"port"
:
3306
,
"user"
:
"DsbuUx"
,
"password"
:
"sfj09JjsfpQx0"
,
"database"
:
"liexin_data_distribution"
},
"redis"
:
{
"host"
:
"172.18.137.38"
,
"port"
:
6379
,
"password"
:
"icDb29mLy2s"
}
}
def
main
():
method_name
=
"jingdong.Timeless.Service.SkuTimeless.modify"
...
...
@@ -41,5 +74,51 @@ def get_goods_info():
ans
=
request_to_jd_vc
(
method_name
,
token
,
app_key
,
app_secret
,
param
)
print
(
json
.
dumps
(
ans
,
ensure_ascii
=
False
))
# 注意 pop店的app_key等信息是不同的。
def
get_pop_class
():
method_name
=
"jingdong.vender.category.getFullValidCategoryResultByVenderId"
token
=
"74ee3f2fa54d489da0d1b94ca83c9bc7lztn"
app_key
=
"CCE6563827D13EDF4769C01E7429378D"
app_secret
=
"98c72374c5b045529879786fc4e5c20e"
param
=
{
}
ans
=
request_to_jd_pop
(
method_name
,
token
,
app_key
,
app_secret
,
param
)
return
ans
def
get_pop_attr
():
method_name
=
"jingdong.category.read.findAttrsByCategoryIdUnlimitCate"
token
=
"74ee3f2fa54d489da0d1b94ca83c9bc7lztn"
app_key
=
"CCE6563827D13EDF4769C01E7429378D"
app_secret
=
"98c72374c5b045529879786fc4e5c20e"
def
insert_pop_class_to_db
():
ans
=
get_pop_class
()
data
=
ans
[
"jingdong_vender_category_getFullValidCategoryResultByVenderId_responce"
][
"returnType"
][
"list"
]
config
=
config_dev
db
=
pymysql
.
connect
(
host
=
config
[
"mysql"
][
"host"
],
port
=
config
[
"mysql"
][
"port"
],
user
=
config
[
"mysql"
][
"user"
],
database
=
config
[
"mysql"
][
"database"
],
password
=
config
[
"mysql"
][
"password"
])
cursor
=
db
.
cursor
()
for
i
in
range
(
len
(
data
)):
parent_id
=
data
[
i
][
"fid"
]
class_id
=
data
[
i
][
"id"
]
class_name
=
data
[
i
][
"name"
]
depth
=
data
[
i
][
"lev"
]
status
=
1
platform
=
3
create_time
=
int
(
time
.
time
())
sql
=
"insert into lie_shop_class (parent_id, class_id, class_name, depth, status, platform, create_time) values (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s)"
cursor
.
execute
(
query
=
sql
,
args
=
(
parent_id
,
class_id
,
class_name
,
depth
,
status
,
platform
,
create_time
))
db
.
commit
()
print
(
sql
%
(
parent_id
,
class_id
,
class_name
,
depth
,
status
,
platform
,
create_time
))
if
__name__
==
'__main__'
:
main
()
\ No newline at end of file
insert_pop_class_to_db
()
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