Commit 0af7f277 by larosa

add py file

parent 37cff675
主要处理京东分类,属性,品牌等数据
需要定时将京东数据更新到本地db中。
import hashlib
import json
import time
import requests
def get_sign_data(method_name, token, app_key, app_secret, param) -> dict:
"""组装京东开放平台api数据,以及添加签名等等"""
json_str = json.dumps(param)
now = int(time.time())
time_array = time.localtime(now)
style = time.strftime("%Y-%m-%d %H:%M:%S", time_array)
data = {
"method": method_name,
"access_token": token,
"app_key": app_key,
"timestamp": style,
"format": "json",
"v": "2.0",
"360buy_param_json": json_str
}
keys = list(data.keys())
keys.sort()
ans = ""
ans += app_secret
for i in range(len(keys)):
ans += keys[i]
ans += data[keys[i]]
ans += app_secret
md = hashlib.md5(ans.encode())
sign = md.hexdigest().upper()
data["sign"] = sign
return data
def request_to_jd_pop():
pass
def request_to_jd_vc(method_name, token, app_key, app_secret, param: dict) -> 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()
{
"jd_url": "https://api.jd.com/routerjson",
"shop_vc": {
"token": "845ce8478b074103b9e78a769d5fa4831y2u",
"app_key": "CA52430E90209F51D8F5D7B615DDE9AD",
"app_secret": "c92691b2379c48de87e699c4c2f7fb32"
},
"json_process_website": "https://www.jyshare.com/front-end/53/"
}
\ No newline at end of file
File mode changed
File mode changed
File mode changed
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment