Commit 108374fa by 岳巧源

add insert pop class

parent dfa8eb46
Showing with 26 additions and 4 deletions
......@@ -87,18 +87,23 @@ def get_pop_class():
ans = request_to_jd_pop(method_name, token, app_key, app_secret, param)
return ans
def get_pop_attr():
def get_pop_attr(class_id: int):
method_name = "jingdong.category.read.findAttrsByCategoryIdUnlimitCate"
token = "74ee3f2fa54d489da0d1b94ca83c9bc7lztn"
app_key = "CCE6563827D13EDF4769C01E7429378D"
app_secret = "98c72374c5b045529879786fc4e5c20e"
param = {
"cid": class_id,
"field": "attrValueList"
}
ans = request_to_jd_pop(method_name, token, app_key, app_secret, param)
print(json.dumps(ans, ensure_ascii=False))
return ans
def insert_pop_class_to_db():
ans = get_pop_class()
data = ans["jingdong_vender_category_getFullValidCategoryResultByVenderId_responce"]["returnType"]["list"]
config = config_dev
config = config_prod
db = pymysql.connect(host=config["mysql"]["host"],
port=config["mysql"]["port"],
user=config["mysql"]["user"],
......@@ -119,6 +124,22 @@ def insert_pop_class_to_db():
print(sql % (parent_id, class_id, class_name, depth, status, platform, create_time))
def insert_pop_attr_to_db():
config = config_dev
select_sql = "select class_id from lie_shop_class where platform = 3"
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()
cursor.execute(query=select_sql)
result = cursor.fetchall()
for i in range(len(result)):
class_id = result[i][0]
if __name__ == '__main__':
insert_pop_class_to_db()
\ No newline at end of file
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